<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Issues with EJB 3 CMP while migrating to jboss-eap-5.0.1
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/praveen_ramisetty">Praveen Ramisetty</a> in <i>EJB 3.0</i> - <a href="http://community.jboss.org/message/566241#566241">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p class="MsoNormal">we observed some issue in our Application while migrating Jboss 4.0.4 to Jboss-EAP-5.0.1.&#160; We are using Containter-Managed Persistence in my project and causing issues when performing Asynchronous transactions (JMS).</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">Before sending message to JMS Queue, my application making an entry in the database. After persisting the record, It sends the Primary Key along with the JMS message.</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In message Driven bean we trying to find the same record using the primary key that we received throught the jms message and failing intermittently. As we are making bulk operation we are able to find the record for some transactions and for some tasks the operation is getting failed.</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">Jboss CMP not persisting the data before sending the message to queue and causing the issue. The code works fine with jboss 4.0.4 but failing with jboss-eap-5.0.1. please give ur suggestions or do i need to do any changes more. Thanks in Advance.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateless</p><p>@Remote({MySession.class})</p><p>public class MySessionBean implements MySession{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@PersistenceContext (unitName="MyApplication")<br/>&#160;&#160;&#160; private EntityManager manager;</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)</p><p class="MsoNormal">public long doSwitchBackhaul(&lt;parameters&gt;){</p><p class="MsoNormal">&#160;&#160;&#160;&#160; ArrayList&lt;Task&gt; taskIdList = createTaskObject();</p><p class="MsoNormal">&#160;&#160;&#160;&#160; scheduleTaskViaJMS(taskIdLIst);</p><p class="MsoNormal">}</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)</p><p class="MsoNormal">public ArrayList&lt;Task&gt; createTaskObject(&lt;parameters&gt;){</p><p class="MsoNormal">&#160;&#160;&#160;&#160; Batch batch = createBatchObject();</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">&#160;&#160;&#160;&#160; for each listof tasks{</p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Code to create Task object&gt;</p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;pass the batch id to Task&gt;</p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; manager.persist(Task)</p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; manager.flush();</p><p class="MsoNormal">&#160;&#160;&#160;&#160; }</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">&#160;&#160;&#160;&#160; return ArrayList&lt;Task&gt; object;</p><p class="MsoNormal">}</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)</p><p class="MsoNormal">public Batch createBatchObject(&lt;parameters&gt;){</p><p class="MsoNormal">&#160;&#160;&#160;&#160; &lt;Code to create Batch Object&gt;</p><p class="MsoNormal">&#160;&#160;&#160;&#160; manager.persist(Batch);</p><p class="MsoNormal">&#160;&#160;&#160;&#160; manager.flush();</p><p class="MsoNormal">&#160;&#160;&#160;&#160; return Batch;</p><p class="MsoNormal">}</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">public void scheduleTaskViaJMS(jbolist){</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">&#160;&#160;&#160;&#160; &lt;code to send the message along with task id to queue&gt;</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">}</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">}</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">@MessageDriven (<br/>&#160;&#160;&#160; activationConfig=<br/>&#160;&#160;&#160; {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName="destination", propertyValue="queue/ProvGuiJobs1")<br/>&#160;&#160;&#160; }<br/>)</p><p class="MsoNormal">public class MDB1 implements MessageListener{</p><p class="MsoNormal">&#160;&#160;&#160;&#160; @PersistenceContext (unitName="MYApplication")<br/>&#160;&#160;&#160; private EntityManager manager;</p><p class="MsoNormal" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="MsoNormal">&#160;&#160;&#160;&#160; public void onMessage(Message message) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Task task = manager.find(Task.class, list.getTaskId()); //Issue is here.. I m not getting all task for few transactions&#160;&#160;&#160;&#160; </p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;do changes to task object&gt;</p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; manager.persist(task);</p><p class="MsoNormal">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; manager.flush();</p><p>&#160;&#160;&#160;&#160; }</p><p class="MsoNormal">}</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/566241#566241">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB 3.0 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>