Chapter 3. Getting started
This chapter guides you through the steps to set up your environment and run a simple messaging program.
3.1. Prerequisites Copy linkLink copied to clipboard!
- You must complete the installation procedure for your environment.
-
You must have an AMQP 1.0 message broker listening for connections on interface
localhostand port5672. It must have anonymous access enabled. For more information, see Starting the broker. -
You must have a queue named
hello-world-example. For more information, see Creating a queue. -
Alternatively, you can specify above information using following environment variables:
HOST,PORT,ADDRESS
3.2. Running HelloWorld on Red Hat Enterprise Linux Copy linkLink copied to clipboard!
The Hello World example creates a connection to the broker, sends a message containing a greeting to the hello-world-example queue, and receives it back. On success, it prints the received message to the console.
Use maven to build the module, and additionally copy the dependencies alongside their output:
cd <source-dir> mvn clean package dependency:copy-dependencies -DincludeScope=runtime -DskipTestsRun the examples:
$ java -cp "target/classes/:target/dependency/*" org.apache.qpid.protonj2.client.examples.HelloWorld
3.3. Running Hello World on Microsoft Windows Copy linkLink copied to clipboard!
The Hello World example creates a connection to the broker, sends a message containing a greeting to the hello-world-example queue, and receives it back. On success, it prints the received message to the console.
Use maven to build the module, and additionally copy the dependencies alongside their output:
cd <source-dir> mvn clean package dependency:copy-dependencies -DincludeScope=runtime -DskipTestsRun the examples:
$ java -cp "target\classes\;target\dependency\*" org.apache.qpid.protonj2.client.examples.HelloWorld