Shubham Rohatgi
Shubham Rohatgi

Reputation: 11

Message storing in topic

In JMS,The messages are stored in a FIFO manner in case of QUEUE.But in case of Topic, How the messages are stored?? Whether in FIFO aur any other manner??

Upvotes: 1

Views: 285

Answers (2)

roundrobin
roundrobin

Reputation: 399

JMS does not make a difference between queues and topics in the point of message ordering. However be aware that the message delivery is not FIFO in every case. The specification states: JMS defines that messages sent by a session to a destination must be received in the order they were sent (see http://docs.oracle.com/cd/E19957-01/816-5904-10/816-5904-10.pdf - chapter 4.4.10) but there are some restrictions, for example with different delivery modes or different priorities.

In many environments you will not find dependent messages sent by one session, as you will find parallelization over multiple servers or processes - therefor it is mostly not a good idea to rely on message order....

Upvotes: 0

John M
John M

Reputation: 13229

FIFO for topics also. That's not the difference between queues and topics.

The big difference between a Queue and a Topic is the messaging model: point-to-point vs publish/subscribe.

  • Queue (Point-to-point): Assume exactly one consumer will get each message. If no consumers listening at the moment, store the message until one arrives. If >1 consumer, randomly pick one consumer to get each message.
  • Topic (Publish/Subscribe): Assume all consumers currently connected get each message sent. For each message sent, arrange for all currently-connected consumers to get a copy. If no consumers currently listening, drop the message.

For this discussion, I'm ignoring durable topic subscriptions. That's a twist on Topic subscribers where messages don't get dropped for that consumer if it isn't listening when the message is sent.

Upvotes: 1

Related Questions