Discussions

EJB design: EJB transaction with JMS

  1. EJB transaction with JMS (3 messages)

    hi,
    In a session bean transation I am inserting a record to the database and putting a message to a JMS queue. The session bean method is transaction enabled and my problem is the JMS message consumer can consume the message before commiting the session bean method transaction.
    Actually the consumer refers to the inserted record to the Database when processing the message, and sometimes it fails since consumer can pop the message from the queue even before session bean commits the transaction. (Database will be updating at the point of session bean commiting the message)
    Please let me know if there is a solution for this issue.

    Threaded Messages (3)

  2. EJB transaction with JMS[ Go to top ]

    Can't you not delay posting the message onto the queue till the Session bean commits the record to the DB? That way you can be sure that when the Consumer picks up the message from the queue/topic, the record will already be there in the Database.

    -Shree
  3. EJB transaction with JMS[ Go to top ]

    Hi!

    I think the "puch to JMS queue" should be a part of the transaction. This means, the message will be rolled back if you (or the EJB container) makes a rollback.

    So, I recommend you to check the transaction handling between the EJB server and the JMS implementation.

    /Tomas
  4. EJB transaction with JMS[ Go to top ]

    I think it depends on whether the bean is Stateful or Stateless if the bean is Stateless then you can use Message Driven Bean instead,
     As there are some similarities between Stateless and Message Driven Bean

    Let me know the problem properly whether u are dealing with stateful or stateless

    Thanks,
    N.Naresh Kumar