Summary
This article explains how to make transient subscriptions.
Explanation
Transient subscription means that the messages are delivered to the message consuming application only when it is running and connected to the broker. Messages that are produced while the consumer application is not running or offline are lost.
To implement transient subscription, use auto-delete option of the queue. If set, queue will be destroyed once the application disconnects from the broker and all messages in the queue will be dropped. When the application reconnects, it will create the queue anew and start receiving messages.
Simple instant messaging application demonstrates the concept of transient queues. Here are the source files:
To compile and link the files set your environment in the same way as you do to build OpenAMQ server and do the following:
$ c -l im_sender.c
Compiling im_sender...
Linking im_sender...
$ c -l im_receiver.c
Compiling im_receiver...
Linking im_receiver...
To run the whole thing, you have to start OpenAMQ server first:
$ amq_server
Once the server is running you can run chatroom window this way:
$ ./im_receiver <broker-address> <chatroom>
For example:
$ ./im_receiver localhost:5672 "OpenAMQ discussion"
To send messages to the chatroom, you have to run sender window this way:
$ ./im_sender <broker-address> <chatroom> <your-name>
For example:
$ ./im_sender 127.0.0.1:5672 "OpenAMQ discussion" "Baron Bartholomaeus von Saburg-Fridetzki"
There can be any number of clients connected to the same chatroom. There's no need to create chatrooms explicitely. These are created on demand.
Comments
Author
- Martin Sustrik <moc.xitami|kirtsus#moc.xitami|kirtsus>

.
Fixed. Sorry for inconvenience.