Announcement Announcement Module
Collapse
No announcement yet.
consume+reply in same transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • consume+reply in same transaction

    Is there a way to ensure that a reply to an incoming message occurs "in the same transaction" as the delivery of the message?

    I believe that SessionAwareMessageListener is intended for that purpose outside of Spring Integration. Although use of the Session supplied via this interface doesn't appear to be supported by JmsTemplate... which is a little inconvenient.

    Also, in the general case, the posting of a message in the same transaction may not strictly be a reply, it could be a forward or transform+forward.

    Thanks in advance,
    S

  • #2
    When a transacted Session is used for receiving Messages, Spring's DefaultMessageListenerContainer does register that Session with the current transaction context (binds it to the current Thread). That also happens to be the same Session that would be passed in an invocation of SessionAwareMessageListener. Therefore, if you are using JmsTemplate downstream but within the scope of a MessageListener invocation managed by DMLC, that JmsTemplate will also find and use that same Session for any send - whether a reply or a forward.

    In Spring Integration, the message-driven inbound adapter uses DMLC and the outbound adapter uses JmsTemplate.

    Does that make sense?
    -Mark

    Comment


    • #3
      It sounds like everything works the way it's supposed to when "sessionTransacted" is set on the DMLC.

      Thanks for the clarification.
      S

      Comment


      • #4
        Were you able to run your application to confirm that it's working as expected?

        Comment


        • #5
          No confirm yet -- we're looking at adopting Spring Integration and this potential issue was one I wanted resolved before switching.

          If you don't hear back from me please assume confirmation!

          thanks again!

          Comment


          • #6
            Originally posted by Mark Fisher View Post
            When a transacted Session is used for receiving Messages, Spring's DefaultMessageListenerContainer does register that Session with the current transaction context (binds it to the current Thread). That also happens to be the same Session that would be passed in an invocation of SessionAwareMessageListener. Therefore, if you are using JmsTemplate downstream but within the scope of a MessageListener invocation managed by DMLC, that JmsTemplate will also find and use that same Session for any send - whether a reply or a forward.

            In Spring Integration, the message-driven inbound adapter uses DMLC and the outbound adapter uses JmsTemplate.

            Does that make sense?
            -Mark
            Mark,
            Does that only work when there is a transaction that spring is managing?
            We want to do this with a JMS transacted session, but with no spring managed transaction because we are in a rather lengthy operation that would normally cause a database transaction to timeout.
            -Jim
            Last edited by jereitz; Aug 5th, 2010, 09:47 AM.

            Comment

            Working...
            X