firefox784
firefox784

Reputation: 667

JMS Message Consumption

I am not sure what happens in the below scenarios, it would be of great help if someone explains it.

Producer (P) sends messages M1, M2 , M3 , M4 , M5, M6 , M7; assuming it is sent from time T1 to T7.

Message Consumer (L) will be a listener bound to the topic. Topic Name : jmsTopic

Scenario 1:

JMS broker is running, L is not connected to jmsTopic. P sends M1 to M7 to jmsTopic. If L is connected to jmsTopic at time say T8 which is greater than T7, will it receive the messages M1 to M7 or only messages that are sent to the topic after time T8.

Scenario 2:

JMS broker is running, L is connected and listening to jmsTopic. P sends M1 to M4. L receives M1 to M4. In the meantime L processes M1 to M4, P sends M5 to M7, however L crashes out during processing of M4. If L again connects itself to jmsTopic does it receive M5 to M7 or only messages that were sent after L has connected to jmsTopic will be received by L.

Scenario 3:

JMS broker is running, L is connected and listening to jmsTopic, P sends M1 to M7. However the broker crashes; is L aware of broker status and reconnects once AMQ is up and running.

Upvotes: 1

Views: 837

Answers (1)

duffymo
duffymo

Reputation: 308733

Scenario 1: AMQ is running, L is not connected to jmsTopic in AMQ. P sends M1 to M7 to jmsTopic. If L is connected to jmsTopic at time say T8 which is greater than T7, will it receive the messages M1 to M7 or only messages that are sent to the topic after time T8.

The whole point of the queue is to guarantee delivery. No messages are processed until a listener takes them off the queue, so all messages that arrive before T8 will be there.

Scenario 2: AMQ is running, L is connected and listening to jmsTopic, P sends M1 to M4. L receives M1 to M4. In the meantime L processes M1 to M4, P sends M5 to M7, however L crashes out during processing of M4. If L again connects itself to jmsTopic , does it receive M5 to M7 or only messages that were sent after L has connected to jmsTopic will be received by L.

Same as #1: all messages M5 and newer will be received by the listener.

Scenario 3: AMQ is running, L is connected and listening to jmsTopic, P sends M1 to M7. However AMQ crashes; is L aware of AMQ status and reconnects once AMQ is up and running.

Set up AMQ for guaranteed delivery; all messages will be serialized to guarantee delivery on receipt.

Upvotes: 1

Related Questions