3 Replies Latest reply on Apr 18, 2011 3:50 PM by andhess

    JBoss AS6 with JPA / JMS timing issue

    andhess

      Hi All

       

      I'm having serious trouble with a software design I'm tring to get to work using JBoss AS6 and PostgreSQL 9.0.3 on CentOS 5.6.

       

      The software works as follows:

       

      Step1

      An EJB has a web-service function with a string parameter. The string data is parsed and written to a @Entity EJB.

      The @Entity bean ist stored to the PostgreSQL database with persist() / flush(). After the record is stored the @Entity bean is also pushed to a JMS queue. The whole is inside a container managed XA transaction.

       

      Step2

      A MDB will process the @Entity bean from the previous step. To be able to manipulate the data it first adds the object to it's local entity manager context using merge().

       

      Step 2 sometimes works as expected and the record is updated, but for about 40-50% of all cases the records gets duplicated. Merge() does not find the record.

      I did a while()-loop to wait until the record becomes available (em.find() == null), but this is NO solution at all.

       

      Looks like a JBoss/JPA/JMP timing issue in combination with PostgreSQL.

       

      Any idea is welcome!

      Thanks in advance

       

      Andreas