1

I want to understand behavior(sync or async) of transacted sessions in spring JMSTemplate while sending non-persistent messages to the ActiveMQ broker. I am talking about the JMSTemplate configuration where Session is transacted and messages sent are non-persistent

According to my understanding:
The non-persistent messages send to the ActiveMQ broker are sent async. But messages send on a transacted session are synchronous. Since commit call is synchronous and JMSTemplate commit after each message sent.

Is message sending with the above specified configuration is synchronous or asynchronous? Please help me to understand this behavior.

Thanks,

Anuj

Anuj Khandelwal
  • 835
  • 2
  • 15
  • 31

1 Answers1

1

The persistence is irrelevant - the commit is a separate operation on the session.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • So irrespective of persistent or non-persistent, the messages sending in a transacted sessions will be synchronous (because commit is synchronous and JMSTemplate commit the session after each message is sent)? – Anuj Khandelwal Jul 17 '14 at 12:51
  • Thanks Gary. Does persistent messages send in a transacted session will have two level of synchronization? First since it is persistent, so sending of messages will be blocked until the message is consumed by the broker. And another is transacted session commit call. – Anuj Khandelwal Jul 28 '14 at 09:48
  • That's a function of your broker and it's client library but, typically, no, the send won't block, only the commit. – Gary Russell Jul 28 '14 at 12:34
  • I am using ActiveMQ as the message broker. "If I send a batch of persistent messages in a transaction, the message sending will be asynchronous. Only commit is synchronous." Is my understanding correct? – Anuj Khandelwal Jul 28 '14 at 14:58
  • I believe so, but I don't know ActiveMQ internals; why don't you run a WireShark trace to confirm? – Gary Russell Jul 28 '14 at 17:39