Reliability

What is Reliability in JMS?

How is Reliability achieved?

There are various properties of JMS which makes it reliable:

1. Acknowledgement

2. Transaction

3. Message Delivery Mode (PERSISTENT & NON_PERSISTENT)

4. Durable Subscription (for Topics)

How is reliability achieved using Message Delivery Mode?

While delivering messages, client can specify with Delivery Mode. By default the delivery mode is PERSISTENT and JMS uses to stick with it, unless the client may bear the loss of messages.

Message Delivery Mode is client or server property. Should not server control it?

Specifying if the message should not Persist-able or not is client specific property and JMS governs it. JMS states clearly that in case of PERSISTED message, client should get ONE AND ONLY ONE message (acknowledgment failure is not treated as duplicate message). However, how the message it stored, the duration, what happens in case of space issue is administrated by MoM.

JMS Specs:

JMS supports two modes of message delivery.

• The NON_PERSISTENT mode is the lowest-overhead delivery mode because it does not require that the message be logged to stable storage. A JMS provider failure can cause a NON_PERSISTENT message to be lost.

• The PERSISTENT mode instructs the JMS provider to take extra care to insure the message is not lost in transit due to a JMS provider failure.

A JMS provider must deliver a NON_PERSISTENT message at-most-once. This means that it may lose the message, but it must not deliver it twice.

A JMS provider must deliver a PERSISTENT message once-and-only-once. This means a JMS provider failure must not cause it to be lost, and it must not deliver it twice.

Should I use PERSISTENT or NON_PERSISTENT Message Deliver mode?

This decision is best example of performance/reliability trade-off. So, the answer is "It Depends on the requirement". But JMS says this also:

Most clients should use producers that produce PERSISTENT messages. In some cases, an application may only require at-most-once message delivery for some of its messages.

So does it mean that NON_PERSISTENT makes JMS application non-reliable?

Yes, absolutely. NON_PERSISTENT messages, non-durable subscriptions, and temporary destinations are by definition unreliable. A JMS provider shutdown or failure will likely cause the loss of NON_PERSISTENT messages and the loss of messages held by temporary destinations and non-durable subscriptions.

Does durable subscription means PERSISTED?

No. It does not. If a NON_PERSISTENT message is delivered to a durable subscription or a queue, delivery is not guaranteed if the JMS provider is shut down and later restarted.