이 콘텐츠는 선택한 언어로 제공되지 않습니다.
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 링크 복사링크가 클립보드에 복사되었습니다!
- To build the example, Maven must be configured to use the Red Hat repository or a local repository.
- You must install the examples.
-
You must have a message broker listening for connections on
localhost. It must have anonymous access enabled. For more information, see Starting the broker. -
You must have a queue named
queue. For more information, see Creating a queue.
3.2. Running Hello World 링크 복사링크가 클립보드에 복사되었습니다!
The Hello World example creates a connection to the broker, sends a message containing a greeting to the queue queue, and receives it back. On success, it prints the received message to the console.
Procedure
Use Maven to build the examples by running the following command in the
<install-dir>/examplesdirectory:mvn clean package dependency:copy-dependencies -DincludeScope=runtime -DskipTests
$ mvn clean package dependency:copy-dependencies -DincludeScope=runtime -DskipTestsCopy to Clipboard Copied! Toggle word wrap Toggle overflow The addition of
dependency:copy-dependenciesresults in the dependencies being copied into thetarget/dependencydirectory.Use the
javacommand to run the example.On Linux or UNIX:
java -cp "target/classes:target/dependency/*" org.apache.qpid.jms.example.HelloWorld
$ java -cp "target/classes:target/dependency/*" org.apache.qpid.jms.example.HelloWorldCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Windows:
> java -cp "target\classes;target\dependency\*" org.apache.qpid.jms.example.HelloWorld
> java -cp "target\classes;target\dependency\*" org.apache.qpid.jms.example.HelloWorldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
For example, running it on Linux results in the following output:
java -cp "target/classes/:target/dependency/*" org.apache.qpid.jms.example.HelloWorld
$ java -cp "target/classes/:target/dependency/*" org.apache.qpid.jms.example.HelloWorld
Hello world!
The source code for the example is in the <install-dir>/examples/src/main/java directory. The JNDI and logging configuration is in the <install-dir>/examples/src/main/resources directory.