3 Replies Latest reply on Feb 25, 2005 5:32 PM by adrian.brock

    sending messages via Transaction Synchronization afterComple

    saylor09

      I'm running jboss 3.2.6 and am attempting to send a single jms message based on a transaction commit. Our system currently employs an ODBMS and we have change events being fired from the persistent objects. Within the coarse of a single ejb call, multiple (and possibly a large number of) changes are possible. I know that i can use java:/JmsXA to get the messages sent on the transaction commit, but (from the point of view of the listener who is just digesting the events) i'd have to queue up a message for each event that my listener receives. I'm thinking it would be better for my listener to queue up the events based on the particular transaction and send a single message containing those events upon a commit. So far, I have attempted to implement this by:

      1. Upon receipt of the event, look up the transaction manager and grab the current transaction
      2. associate (at first time) a Synchronization with the current transaction
      3. continue to register all events for that given transaction
      4. upon commit, the Synchronization get's a call to afterCompletion() and if STATUS_COMMITTED, publish a single message containing all the event data

      As i know that i'm outside the scope of a transaction at this point, I'm creating a TopicSession (via java:/JmsXA) with transacted = false, but i'm getting:

      javax.jms.IllegalStateException: The session is closed

      when attempting to publish (and other various related messages about connections being closed for me by the CachedConnectionManager and prepare being called on a local tx).

      At this point I'm trying to figure out, is using the Synchronization in this way an OK thing to do. If so, how can i send a simple jms message in this way?

      Thanks

      Scott