• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MDB starts before Queue send is commited

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

I have the following problem: In a SLSB I send a message to a JMS queue. I need the JMSMessageID from the message to create a EntityBean which I also do in the same SLSB and within the same transaction.

The MDB that gets started with this message now changes a state of exactly this EntityBean, but my problem is, that the MDB already gets started before my SLSB tries to create the EntityBean, so I get a ObjectNotFoundExeption while trying to update the EntityBean.

I expect the WLS Container to wait until the SLSB transaction (attribute Required) is commited. Do I have to set a flag anywhere to do this or is this behaviour normal?

Any hints are appreciated!
Stephan
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you get your QueueConnectionFactory / Queue? Through the container, I guess?

Did you specify the transaction behaviour of your JMS-Session as "transacted"? (Argument true)?
 
Stephan Staeheli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Severin St�ckli:
How do you get your QueueConnectionFactory / Queue? Through the container, I guess?



Yes, I did.

Originally posted by Severin St�ckli:
Did you specify the transaction behaviour of your JMS-Session as "transacted"? (Argument true)?



No, I have false and CLIENT_ACKNOWLEDGE as parameters.

I have changed my JMS definition that the Connection Factory is XA-enabled. I also activated a flag that my JDBC Data Sources emulates a 2-phase commit. Now I works as I expected it.

I thought XA is only necessary when you have transaction running on more than one application server? Am I wrong?

Regards,
Stephan
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stephan (chasch d��tsch? ;-)

I thought XA is only necessary when you have transaction running on more than one application server? Am I wrong?

Yes, you're wrong. As soon as you have one single transaction distributed over two different data sources, you need XA. How else can the container assure that the Transaction (for datasource DB and for datasource MDB) is committed at the "same" time?

Question: which attributes did you set? The correct settings for your problem are (in my opinion):

- SLSB CMT RequiresNew
- Entity Bean: CMT, Required
- JMS: transaction: true, ack-method 0

See also J2EE Tutorial Managing Distributed Transactions:

When you create a session in an enterprise bean, the container ignores the arguments you specify, because it manages all transactional properties for enterprise beans. It is still a good idea to specify arguments of true and 0 to the createSession method to make this situation clear:

session = connection.createSession(true, 0);

When you use container-managed transactions, you usually specify the Required transaction attribute for your enterprise bean's business methods.



/severin
 
Stephan Staeheli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Severin (jo, ich cha d��tsch)

Thanks for your help, everything works fine now.

Stephan
 
reply
    Bookmark Topic Watch Topic
  • New Topic