Chapter 3. Getting started
This chapter guides you through a simple exercise to help you get started using AMQ Python.
3.1. Preparing the broker Copy linkLink copied to clipboard!
The example programs require a running broker with a queue named examples
. Follow these steps to define the queue and start the broker:
Procedure
- Install the broker.
- Create a broker instance. Enable anonymous access.
Start the broker instance and check the console for any critical errors logged during startup.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
artemis queue
command to create a queue calledexamples
.<broker-instance-dir>/bin/artemis queue create --name examples --auto-create-address --anycast
<broker-instance-dir>/bin/artemis queue create --name examples --auto-create-address --anycast
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You are prompted to answer a series of questions. For yes or no questions, type
N
. Otherwise, press Enter to accept the default value.
3.2. Running Hello World Copy linkLink copied to clipboard!
The Hello World example sends a message to the examples
queue on the broker and then fetches it back. On success it prints Hello World!
to the console.
Using a new terminal window, change directory to the AMQ Python examples directory and run the helloworld.py
example.
cd /usr/share/proton-0.28.0/examples/python/ python helloworld.py
$ cd /usr/share/proton-0.28.0/examples/python/
$ python helloworld.py
Hello World!