0

I have a some questions regarding transactions in DMLC and JMSTemplate.

  1. Does Spring DMLC receive messages asynchronously using callbacks if we are not using transactions ?

  2. Does DMLC also receive messages asynchronous while using transacted session. (setting sessionTransacted to true). What is the behavior after setting sessionTransacted to true ?

3, What is the difference between AUTO_ACK and SESSION_TRANSACTED mode from consumer's prospective. In AUTO_ACK mode DMLC send acknowledgement to the broker after message is received. Similarly in SESSION_TRANSACTED mode DMLC commits after each message received. Which is the better way in terms of performance and what is the difference?

4 Does JMSTemplate message sending is always synchronous. Even if It is sending non persistent messages to a topic ?

Thanks, Anuj

Anuj Khandelwal
  • 835
  • 2
  • 15
  • 31

1 Answers1

0

The DMLC is not receommended to be used without transactions; use the SMLC.

When using transactions, the container commits the session when the thread returns. Yes, they are handled asynchronously.

With auto ack and the DMLC, the session is acked as soon as the receive() happens (and before the listener is invoked) - hence it really is best for transactions.

  1. That's a function of the JMS client library but generally, yes; especially if using transactions.
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Thanks Gary. Is there any reason why DMLC should be used with transactions ? Another thing is-- As you said ""With auto ack and the DMLC, the session is acked as soon as the receive() happens (and before the listener is invoked) - hence it really is best for transactions."" ---- I am little bit confused here. I think AUTO_ACK mode is not even respected if session is transacted. I want to know what are the difference between AUTO_ACK and SESSION_TRANSACTED mode if both send ack (ack or commit respectively) after each message received? Which one is better in terms of performance? – Anuj Khandelwal Jun 18 '14 at 05:08
  • I said it usually is ONLY used with transactions because the message is acked automatically (with AUTO_ACK) as soon as the message is received and before the listener is invoked. With transactions, the message receive is committed AFTER the listener returns. So it's not a question of performance it's a question of resilience/recovery; with transactions you won't lose messages, with AUTO_ACK (and DMLC), you might. If you use the SMLC, the client library does the ack after the listener returns. Read the javadocs for SMLC/DMLC for comparison. – Gary Russell Jun 18 '14 at 12:24
  • Thanks for the response Gary. Does JMSTemplate message sending is always synchronous. Even if it uses transactions or without transactions? – Anuj Khandelwal Jun 18 '14 at 15:11
  • As I said, that's a function of your provider's library. They may, or may not use an ack for non-transactional sends. – Gary Russell Jun 18 '14 at 15:47
  • I am using ActiveMQ broker. Is there a way to send messages Asynchronously to the broker using JMSTemplate ? – Anuj Khandelwal Jun 19 '14 at 04:47
  • One more time - that is a function of the JMS library - the `JmsTemplate` is just a client of that library. I don't know the internals of activemq and whether it has any kind of ack for non-transactional send but if you use the native JMS api you will get the same result as the JmsTemplate. (It probably doesn't have an ack but you can use wireshark to confirm). – Gary Russell Jun 19 '14 at 12:31