In the Chat application, whenever anyone sends a
text message to a given topic, all active applications running
Chat receive that message as subscribers to that
topic. This is the most basic form of publish and subscribe
activity.
To run the chat sample do the following:
In window 1, enter:
ant chat1, then typeHello, and press Enter.Window 1 displays:
Chatter_1: HelloIn window 2, enter:
ant chat2, then typePronto, and press Enter.Both subscribers get the message so both windows display:
Chatter_2: ProntoIn window 3, enter:
ant chat3, then typeBonjour, and press Enter.All three subscribers get the message, so each window displays:
Chatter_3: BonjourIn window 3, stop
chat3by pressing Ctrl+C.Send some messages in the
chat1andchat2windows.In window 3, run:
ant chat3again.Send some messages in the
chat1andchat2windows.All three subscribers get the message. But
Chatter_3gets only the messages since it reconnected, and gets none of the messages that were sent while it was disconnected.If subscribers miss some of the messages, they pick up just the latest messages whenever they reconnect to the broker. Nothing is retained and nothing is guaranteed to be delivered, so throughput is fast.








