6.6.4. Last Value Queue Command-line Example
The included programs
drain
and spout
can be used for sending and receiving messages for testing purposes. The source code for the two utilities is included in the Python and C++ client library packages. The Python version can be run uncompiled using a Python interpreter.
Run the following
qpid-config
command to create a Last Value Queue:
qpid-config add queue my-queue --argument qpid.last_value_queue_key=type
The header key '
type
' is used to match messages in the queue.
Now start one or more browsers using the
drain
command:
./drain -f -c 0 'my-queue; {mode: browse}'
These browsers will see all the messages as they arrive in the queue in real-time.
Now use
spout
to send messages to the queue, setting a header value for the key 'type
':
./spout -P type=a my-queue a1 ./spout -P type=a my-queue a2 ./spout -P type=a my-queue a3 ./spout -P type=b my-queue b1 ./spout -P type=c my-queue c1 ./spout -P type=c my-queue c2 ./spout -P type=a my-queue a4
The browsers started before these messages were published will see all messages as they arrive.
Now start a new browser:
./drain -c 0 'my-queue; {mode: browse}'
This browser will see only the last messages for each of the unique '
type
' values.