user982733
user982733

Reputation:

JMS Transactions - overhead - how to avoid it, if possible?

In our application, we receive messages from JMS Topic.

We consume messages ( durable subscriber and JMS session is transacted, lot of overhead ) because messages are retained at the JMS server until the transaction commits/ends. The reason we specified transaction is

Upvotes: 0

Views: 1032

Answers (1)

Nicholas
Nicholas

Reputation: 16066

Message ordering for topics is not specified in the JMS spec so the official answer to that is that it is JMS implementation specific. Having said that, unless specifically overridden to do something else, I imagine that messages would be delivered in FIFO order.

For the transactions, I suggest you look into implementing two phase commit XA transactions so you do not need two separate transactions. If your cache implementation supports XA, the JMS and Cache(and DB) transactions would be one and the same.

Generally I have found that for these types of transacted messages, if you must used transacted messages, the best way to squeeze performance out is to process as many messages in one transaction as you can:

  1. Start a transaction
  2. Retrieve n messages (or all of them until there is a timeout)
  3. Process the messages
  4. Commit the transaction.
  5. Go To 1.

Another way to kill 2 birds with 1 stone is to skip the processing of the message during retrieval and simply write the retrieved messages to a transacted data store. Then have a separate thread retrieve the messages from the store (in timestamp order) and process them (separate thread - = separate transaction).

Upvotes: 1

Related Questions