Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 4. Examples
This chapter demonstrates the use of AMQ C++ through example programs. To run them, make sure you have completed the steps in the Chapter 2, Installation chapter for your environment and you have a running and configured broker.
See the Qpid Proton C++ examples for more sample programs.
4.1. Sending Messages Copier lienLien copié sur presse-papiers!
This client program connects to a server using CONNECTION_URL
, creates a sender for target ADDRESS
, sends a message containing MESSAGE_BODY
, closes the connection, and exits.
Example: Sending Messages
Running the Example
To run the example program, copy it to a local file, compile it, and execute it from the command line.
g++ send.cpp -o send -std=c++11 -lstdc++ -lqpid-proton-cpp ./send amqp://localhost queue1 hello
$ g++ send.cpp -o send -std=c++11 -lstdc++ -lqpid-proton-cpp
$ ./send amqp://localhost queue1 hello
4.2. Receiving Messages Copier lienLien copié sur presse-papiers!
This client program connects to a server using CONNECTION_URL
, creates a receiver for source ADDRESS
, and receives messages until it is terminated or it reaches COUNT
messages.
Example: Receiving Messages
Running the Example
To run the example program, copy it to a local file, compile it, and execute it from the command line.
g++ receive.cpp -o receive -std=c++11 -lstdc++ -lqpid-proton-cpp ./receive amqp://localhost queue1
$ g++ receive.cpp -o receive -std=c++11 -lstdc++ -lqpid-proton-cpp
$ ./receive amqp://localhost queue1