Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Using the AMQ OpenWire JMS Client
For Use with AMQ Clients 2.7
Abstract
Chapter 1. Overview Link kopierenLink in die Zwischenablage kopiert!
AMQ OpenWire JMS is a Java Message Service (JMS) 1.1 client for use in messaging applications that send and receive OpenWire messages.
AMQ OpenWire JMS is part of AMQ Clients, a suite of messaging libraries supporting multiple languages and platforms. For an overview of the clients, see AMQ Clients Overview. For information about this release, see AMQ Clients 2.7 Release Notes.
AMQ OpenWire JMS is based on the JMS implementation from Apache ActiveMQ. For more information about the JMS API, see the JMS API reference and the JMS tutorial.
1.1. Key features Link kopierenLink in die Zwischenablage kopiert!
- JMS 1.1 compatible
- SSL/TLS for secure communication
- Automatic reconnect and failover
- Distributed transactions (XA)
- Pure-Java implementation
1.2. Supported standards and protocols Link kopierenLink in die Zwischenablage kopiert!
AMQ OpenWire JMS supports the following industry-recognized standards and network protocols:
- Version 1.1 of the Java Message Service API.
- Modern TCP with IPv6
1.3. Supported configurations Link kopierenLink in die Zwischenablage kopiert!
AMQ OpenWire JMS supports the OS and language versions listed below. For more information, see Red Hat AMQ 7 Supported Configurations.
Red Hat Enterprise Linux 7 and 8 with the following JDKs:
- OpenJDK 8 and 11
- Oracle JDK 8
- IBM JDK 8
Red Hat Enterprise Linux 6 with the following JDKs:
- OpenJDK 8
- Oracle JDK 8
- IBM AIX 7.1 with IBM JDK 8
- Microsoft Windows 10 Pro with Oracle JDK 8
- Microsoft Windows Server 2012 R2 and 2016 with Oracle JDK 8
- Oracle Solaris 10 and 11 with Oracle JDK 8
AMQ OpenWire JMS is supported in combination with the following AMQ components and versions:
- The latest version of AMQ Broker
- A-MQ 6 versions 6.2.1 and newer
1.4. Terms and concepts Link kopierenLink in die Zwischenablage kopiert!
This section introduces the core API entities and describes how they operate together.
| Entity | Description |
|---|---|
|
| An entry point for creating connections. |
|
| A channel for communication between two peers on a network. It contains sessions. |
|
| A context for producing and consuming messages. It contains message producers and consumers. |
|
| A channel for sending messages to a destination. It has a target destination. |
|
| A channel for receiving messages from a destination. It has a source destination. |
|
| A named location for messages, either a queue or a topic. |
|
| A stored sequence of messages. |
|
| A stored sequence of messages for multicast distribution. |
|
| An application-specific piece of information. |
AMQ OpenWire JMS sends and receives messages. Messages are transferred between connected peers using message producers and consumers. Producers and consumers are established over sessions. Sessions are established over connections. Connections are created by connection factories.
A sending peer creates a producer to send messages. The producer has a destination that identifies a target queue or topic at the remote peer. A receiving peer creates a consumer to receive messages. Like the producer, the consumer has a destination that identifies a source queue or topic at the remote peer.
A destination is either a queue or a topic. In JMS, queues and topics are client-side representations of named broker entities that hold messages.
A queue implements point-to-point semantics. Each message is seen by only one consumer, and the message is removed from the queue after it is read. A topic implements publish-subscribe semantics. Each message is seen by multiple consumers, and the message remains available to other consumers after it is read.
See the JMS tutorial for more information.
1.5. Document conventions Link kopierenLink in die Zwischenablage kopiert!
The sudo command
In this document, sudo is used for any command that requires root privileges. Exercise caution when using sudo because any changes can affect the entire system. For more information about sudo, see Using the sudo command.
File paths
In this document, all file paths are valid for Linux, UNIX, and similar operating systems (for example, /home/andrea). On Microsoft Windows, you must use the equivalent Windows paths (for example, C:\Users\andrea).
Variable text
This document contains code blocks with variables that you must replace with values specific to your environment. Variable text is enclosed in arrow braces and styled as italic monospace. For example, in the following command, replace <project-dir> with the value for your environment:
cd <project-dir>
$ cd <project-dir>
Chapter 2. Installation Link kopierenLink in die Zwischenablage kopiert!
This chapter guides you through the steps to install AMQ OpenWire JMS in your environment.
2.1. Prerequisites Link kopierenLink in die Zwischenablage kopiert!
- You must have a subscription to access AMQ release files and repositories.
- To build programs with AMQ OpenWire JMS, you must install Apache Maven.
- To use AMQ OpenWire JMS, you must install Java.
2.2. Using the Red Hat Maven repository Link kopierenLink in die Zwischenablage kopiert!
Configure your Maven environment to download the client library from the Red Hat Maven repository.
Procedure
Add the Red Hat repository to your Maven settings or POM file. For example configuration files, see Section B.1, “Using the online repository”.
<repository> <id>red-hat-ga</id> <url>https://maven.repository.redhat.com/ga</url> </repository>
<repository> <id>red-hat-ga</id> <url>https://maven.repository.redhat.com/ga</url> </repository>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the library dependency to your POM file.
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-client</artifactId> <version>5.11.0.redhat-630416</version> </dependency>
<dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-client</artifactId> <version>5.11.0.redhat-630416</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The client is now available in your Maven project.
2.3. Installing a local Maven repository Link kopierenLink in die Zwischenablage kopiert!
As an alternative to the online repository, AMQ OpenWire JMS can be installed to your local filesystem as a file-based Maven repository.
Procedure
- Use your subscription to download the AMQ Broker 7.6.0 Maven repository .zip file.
Extract the file contents into a directory of your choosing.
On Linux or UNIX, use the
unzipcommand to extract the file contents.unzip amq-broker-7.6.0-maven-repository.zip
$ unzip amq-broker-7.6.0-maven-repository.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Windows, right-click the .zip file and select Extract All.
-
Configure Maven to use the repository in the
maven-repositorydirectory inside the extracted install directory. For more information, see Section B.2, “Using a local repository”.
2.4. Installing the examples Link kopierenLink in die Zwischenablage kopiert!
Procedure
- Use your subscription to download the AMQ Broker 7.6.0 .zip file.
Extract the file contents into a directory of your choosing.
On Linux or UNIX, use the
unzipcommand to extract the file contents.unzip amq-broker-7.6.0.zip
$ unzip amq-broker-7.6.0.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Windows, right-click the .zip file and select Extract All.
When you extract the contents of the .zip file, a directory named
amq-broker-7.6.0is created. This is the top-level directory of the installation and is referred to as<install-dir>throughout this document.
Chapter 3. Getting started Link kopierenLink in die Zwischenablage kopiert!
This chapter guides you through the steps to set up your environment and run a simple messaging program.
3.1. Prerequisites Link kopierenLink in die Zwischenablage kopiert!
- 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
exampleQueue. For more information, see Creating a queue.
3.2. Running your first example Link kopierenLink in die Zwischenablage kopiert!
The example creates a consumer and producer for a queue named exampleQueue. It sends a text message and then receives it back, printing the received message to the console.
Procedure
Use Maven to build the examples by running the following command in the
<install-dir>/examples/protocols/openwire/queuedirectory.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.activemq.artemis.jms.example.QueueExample
$ java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Windows:
> java -cp "target\classes;target\dependency\*" org.apache.activemq.artemis.jms.example.QueueExample
> java -cp "target\classes;target\dependency\*" org.apache.activemq.artemis.jms.example.QueueExampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Running it on Linux results in the following output:
java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExample
$ java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExample
Sent message: This is a text message
Received message: This is a text message
The source code for the example is in the <install-dir>/examples/protocols/openwire/queue/src directory. Additional examples are available in the <install-dir>/examples/protocols/openwire directory.
Chapter 4. Configuration Link kopierenLink in die Zwischenablage kopiert!
This chapter describes the process for binding the AMQ OpenWire JMS implementation to your JMS application and setting configuration options.
JMS uses the Java Naming Directory Interface (JNDI) to register and look up API implementations and other resources. This enables you to write code to the JMS API without tying it to a particular implementation.
Configuration options are exposed as query parameters on the connection URI. Some of the options are also exposed as corresponding set and get methods on the ConnectionFactory implementation object.
For more information about configuring AMQ OpenWire JMS, see the ActiveMQ user guide.
4.1. Configuring the initial context factory Link kopierenLink in die Zwischenablage kopiert!
JMS applications use a JNDI InitialContext object obtained from an InitialContextFactory to look up JMS objects such as the connection factory. AMQ OpenWire JMS provides an implementation of the InitialContextFactory in the org.apache.activemq.jndi.ActiveMQInitialContextFactory class.
The InitialContextFactory implementation is discovered when the InitialContext object is instantiated:
javax.naming.Context context = new javax.naming.InitialContext();
javax.naming.Context context = new javax.naming.InitialContext();
To find an implementation, JNDI must be configured in your environment. There are two main ways of achieving this, using a jndi.properties file or using a system property.
Using a jndi.properties file
Create a file named jndi.properties and place it on the Java classpath. Add a property with the key java.naming.factory.initial.
Example: Setting the JNDI initial context factory using a jndi.properties file
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
In Maven-based projects, the jndi.properties file is placed in the <project-dir>/src/main/resources directory.
Using a system property
Set the java.naming.factory.initial system property.
Example: Setting the JNDI initial context factory using a system property
java -Djava.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory ...
$ java -Djava.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory ...
4.2. Configuring the connection factory Link kopierenLink in die Zwischenablage kopiert!
The JMS connection factory is the entry point for creating connections. It uses a connection URI that encodes your application-specific configuration settings.
To set the factory name and connection URI, create a property in the format below. You can store this configuration in a jndi.properties file or set the corresponding system property.
The JNDI property format for connection factories
connectionFactory.<factory-name> = <connection-uri>
connectionFactory.<factory-name> = <connection-uri>
For example, this is how you might configure a factory named app1:
Example: Setting the connection factory in a jndi.properties file
connectionFactory.app1 = tcp://example.net:61616?jms.clientID=backend
connectionFactory.app1 = tcp://example.net:61616?jms.clientID=backend
You can then use the JNDI context to look up your configured connection factory using the name app1:
ConnectionFactory factory = (ConnectionFactory) context.lookup("app1");
ConnectionFactory factory = (ConnectionFactory) context.lookup("app1");
4.3. Connection URIs Link kopierenLink in die Zwischenablage kopiert!
A connection factory is configured using a connection URI in the following format:
The Connection URI format
<scheme>://<host>:<port>[?<option>=<value>[&<option>=<value>...]]
<scheme>://<host>:<port>[?<option>=<value>[&<option>=<value>...]]
The scheme is tcp for unencrypted connections and ssl for SSL/TLS connections.
For example, the following is a connection URI that connects to host example.net at port 61616 and sets the client ID to backend:
Example: A connection URI
tcp://example.net:61616?jms.clientID=backend
tcp://example.net:61616?jms.clientID=backend
Failover URIs take the following form:
The failover URI format
failover:(<connection-uri>[,<connection-uri>])[?<option>=<value>[&<option>=<value>...]]
failover:(<connection-uri>[,<connection-uri>])[?<option>=<value>[&<option>=<value>...]]
Options prefixed with nested. are applied to each connection URI in the list.
The available connection options are described in the following sections.
4.4. JMS options Link kopierenLink in die Zwischenablage kopiert!
- jms.username
- The user name used to authenticate the connection.
- jms.password
- The password used to authenticate the connection.
- jms.clientID
- The client ID that is applied to the connection.
- jms.closeTimeout
- The close timeout in milliseconds. The default is 15000 (15 seconds).
- jms.checkForDuplicates
- If enabled, ignore duplicate messages. It is enabled by default.
- jms.disableTimeStampsByDefault
- If enabled, do not timestamp messages. It is disabled by default.
- jms.useAsyncSend
- If enabled, send messages without waiting for acknowledgment. It is disabled by default.
- jms.alwaysSyncSend
- If enabled, send waits for acknowledgment in all delivery modes. It is disabled by default.
- jms.useCompression
- If enabled, compress message bodies. It is disabled by default.
- jms.useRetroactiveConsumer
- If enabled, non-durable subscribers can receive messages that were published before the subscription started. It is disabled by default.
Prefetch policy options
Prefetch policy determines how many messages each MessageConsumer will fetch from the remote peer and hold in a local "prefetch" buffer.
- jms.prefetchPolicy.queuePrefetch
- The number of messages to prefetch for queues. The default is 1000.
- jms.prefetchPolicy.queueBrowserPrefetch
- The number of messages to prefetch for queue browsers. The default is 500.
- jms.prefetchPolicy.topicPrefetch
- The number of messages to prefetch for non-durable topics. The default is 32766.
- jms.prefetchPolicy.durableTopicPrefetch
- The number of messages to prefetch for durable topics. The default is 100.
- jms.prefetchPolicy.all
- This can be used to set all prefetch values at once.
The value of prefetch can affect the distribution of messages to multiple consumers on a queue or shared subscription. A higher value can result in larger batches sent at once to each consumer. To achieve more even round-robin distribution, use a lower value.
Redelivery policy options
Redelivery policy controls how redelivered messages are handled on the client.
- jms.redeliveryPolicy.maximumRedeliveries
- The number of times redelivery is attempted before the message is sent to the dead letter queue. The default is 6. -1 means no limit.
- jms.redeliveryPolicy.redeliveryDelay
-
The time in milliseconds between redelivery attempts. This is used if
initialRedeliveryDelayis 0. The default is 1000 (1 second). - jms.redeliveryPolicy.initialRedeliveryDelay
- The time in milliseconds before the first redelivery attempt. The default is 1000 (1 second).
- jms.redeliveryPolicy.maximumRedeliveryDelay
-
The maximum time in milliseconds between redelivery attempts. This is used if
useExponentialBackOffis enabled. The default is 1000 (1 second). -1 means no limit. - jms.redeliveryPolicy.useExponentialBackOff
- If enabled, increase redelivery delay with each subsequent attempt. It is disabled by default.
- jms.redeliveryPolicy.backOffMultiplier
- The multiplier for increasing the redelivery delay. The default is 5.
- jms.redeliveryPolicy.useCollisionAvoidance
- If enabled, adjust the redelivery delay slightly up or down to avoid collisions. It is disabled by default.
- jms.redeliveryPolicy.collisionAvoidanceFactor
- The multiplier for adjusting the redelivery delay. The default is 0.15.
4.5. TCP options Link kopierenLink in die Zwischenablage kopiert!
- connectionTimeout
- The connection timeout in milliseconds. The default is 30000 (30 seconds). 0 means no timeout.
- ioBufferSize
- The I/O buffer size in bytes. The default is 8192 (8 KiB).
- useKeepAlive
- If enabled, periodically send data to keep the connection alive. It is enabled by default.
- soTimeout
- The socket read timeout. The default is 0, meaning no timeout.
- soWriteTimeout
- The socket write timeout. The default is 0, meaning no timeout.
- tcpNoDelay
- If enabled, do not delay and buffer TCP sends. It is disabled by default.
4.6. Failover options Link kopierenLink in die Zwischenablage kopiert!
- maxReconnectAttempts
- The number of reconnect attempts allowed before reporting the connection as failed. The default is -1, meaning no limit. 0 disables reconnect.
- maxReconnectDelay
- The maximum time in milliseconds between the second and subsequent reconnect attempts. The default is 30000 (30 seconds).
- randomize
- If enabled, randomly select one of the failover endpoints. It is enabled by default.
- reconnectDelayExponent
- The multiplier for increasing the reconnect delay backoff. The default is 2.0.
- useExponentialBackOff
- If enabled, increase the reconnect delay with each subsequent attempt. It is enabled by default.
4.7. SSL/TLS options Link kopierenLink in die Zwischenablage kopiert!
- socket.keyStore
-
The path to the SSL/TLS key store. A key store is required for mutual SSL/TLS authentication. If unset, the value of the
javax.net.ssl.keyStoresystem property is used. - socket.keyStorePassword
-
The password for the SSL/TLS key store. If unset, the value of the
javax.net.ssl.keyStorePasswordsystem property is used. - socket.trustStore
-
The path to the SSL/TLS trust store. If unset, the value of the
javax.net.ssl.trustStoresystem property is used. - socket.trustStorePassword
-
The password for the SSL/TLS trust store. If unset, the value of the
javax.net.ssl.trustStorePasswordsystem property is used. - socket.enabledCipherSuites
- A comma-separated list of cipher suites to enable. If unset, the JVM default ciphers are used.
- socket.enabledProtocols
- A comma-separated list of SSL/TLS protocols to enable. If unset, the JVM default protocols are used.
4.8. Large message options Link kopierenLink in die Zwischenablage kopiert!
The client can enable large message support by setting a value for the property wireFormat.minLargeMessageSize. Any message larger than wireFormat.minLargeMessageSize is considered a large message.
- wireFormat.minLargeMessageSize
- The minimum size in bytes at which a message is treated as a large message. The default is 102400 (100 KiB).
- wireFormat.compressLargeMessages
If enabled, compress large messages, as defined by
wireFormat.minLargeMessageSize. It is disabled by default.NoteIf the compressed size of a large message is less than the value of
wireFormat.minLargeMessageSize, the message is sent as a regular message. Therefore, it is not written to the broker’s large-message data directory.
4.9. Configuring JNDI resources Link kopierenLink in die Zwischenablage kopiert!
4.9.1. Configuring queue and topic names Link kopierenLink in die Zwischenablage kopiert!
JMS provides the option of using JNDI to look up deployment-specific queue and topic resources.
To set queue and topic names in JNDI, create properties in the following format. Either place this configuration in a jndi.properties file or define corresponding system properties.
The JNDI property format for queues and topics
queue.<queue-lookup-name> = <queue-name> topic.<topic-lookup-name> = <topic-name>
queue.<queue-lookup-name> = <queue-name>
topic.<topic-lookup-name> = <topic-name>
For example, the following properties define the names jobs and notifications for two deployment-specific resources:
Example: Setting queue and topic names in a jndi.properties file
queue.jobs = app1/work-items topic.notifications = app1/updates
queue.jobs = app1/work-items
topic.notifications = app1/updates
You can then look up the resources by their JNDI names:
Queue queue = (Queue) context.lookup("jobs");
Topic topic = (Topic) context.lookup("notifications");
Queue queue = (Queue) context.lookup("jobs");
Topic topic = (Topic) context.lookup("notifications");
4.9.2. Setting JNDI properties programatically Link kopierenLink in die Zwischenablage kopiert!
As an alternative to using a jndi.properties file or system properties to configure JNDI, you can define properties programatically using the JNDI initial context API.
Example: Setting JNDI properties programatically
Chapter 5. Message delivery Link kopierenLink in die Zwischenablage kopiert!
5.1. Writing to a streamed large message Link kopierenLink in die Zwischenablage kopiert!
To write to a large message, use the BytesMessage.writeBytes() method. The following example reads bytes from a file and writes them to a message:
Example: Writing to a streamed large message
5.2. Reading from a streamed large message Link kopierenLink in die Zwischenablage kopiert!
To read from a large message, use the BytesMessage.readBytes() method. The following example reads bytes from a message and writes them to a file:
Example: Reading from a streamed large message
Appendix A. Using your subscription Link kopierenLink in die Zwischenablage kopiert!
AMQ is provided through a software subscription. To manage your subscriptions, access your account at the Red Hat Customer Portal.
A.1. Accessing your account Link kopierenLink in die Zwischenablage kopiert!
Procedure
- Go to access.redhat.com.
- If you do not already have an account, create one.
- Log in to your account.
A.2. Activating a subscription Link kopierenLink in die Zwischenablage kopiert!
Procedure
- Go to access.redhat.com.
- Navigate to My Subscriptions.
- Navigate to Activate a subscription and enter your 16-digit activation number.
A.3. Downloading release files Link kopierenLink in die Zwischenablage kopiert!
To access .zip, .tar.gz, and other release files, use the customer portal to find the relevant files for download. If you are using RPM packages or the Red Hat Maven repository, this step is not required.
Procedure
- Open a browser and log in to the Red Hat Customer Portal Product Downloads page at access.redhat.com/downloads.
- Locate the Red Hat AMQ entries in the INTEGRATION AND AUTOMATION category.
- Select the desired AMQ product. The Software Downloads page opens.
- Click the Download link for your component.
A.4. Registering your system for packages Link kopierenLink in die Zwischenablage kopiert!
To install RPM packages on Red Hat Enterprise Linux, your system must be registered. If you are using downloaded release files, this step is not required.
Procedure
- Go to access.redhat.com.
- Navigate to Registration Assistant.
- Select your OS version and continue to the next page.
- Use the listed command in your system terminal to complete the registration.
For more information, see How to Register and Subscribe a System to the Red Hat Customer Portal.
Appendix B. Using Red Hat Maven repositories Link kopierenLink in die Zwischenablage kopiert!
This section describes how to use Red Hat-provided Maven repositories in your software.
B.1. Using the online repository Link kopierenLink in die Zwischenablage kopiert!
Red Hat maintains a central Maven repository for use with your Maven-based projects. For more information, see the repository welcome page.
There are two ways to configure Maven to use the Red Hat repository:
Adding the repository to your Maven settings
This method of configuration applies to all Maven projects owned by your user, as long as your POM file does not override the repository configuration and the included profile is enabled.
Procedure
Locate the Maven
settings.xmlfile. It is usually inside the.m2directory in the user home directory. If the file does not exist, use a text editor to create it.On Linux or UNIX:
/home/<username>/.m2/settings.xml
/home/<username>/.m2/settings.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Windows:
C:\Users\<username>\.m2\settings.xml
C:\Users\<username>\.m2\settings.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a new profile containing the Red Hat repository to the
profileselement of thesettings.xmlfile, as in the following example:Example: A Maven
settings.xmlfile containing the Red Hat repositoryCopy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information about Maven configuration, see the Maven settings reference.
Adding the repository to your POM file
To configure a repository directly in your project, add a new entry to the repositories element of your POM file, as in the following example:
Example: A Maven pom.xml file containing the Red Hat repository
For more information about POM file configuration, see the Maven POM reference.
B.2. Using a local repository Link kopierenLink in die Zwischenablage kopiert!
Red Hat provides file-based Maven repositories for some of its components. These are delivered as downloadable archives that you can extract to your local filesystem.
To configure Maven to use a locally extracted repository, apply the following XML in your Maven settings or POM file:
<repository>
<id>red-hat-local</id>
<url>${repository-url}</url>
</repository>
<repository>
<id>red-hat-local</id>
<url>${repository-url}</url>
</repository>
${repository-url} must be a file URL containing the local filesystem path of the extracted repository.
| Operating system | Filesystem path | URL |
|---|---|---|
| Linux or UNIX |
|
|
| Windows |
|
|
Appendix C. Using AMQ Broker with the examples Link kopierenLink in die Zwischenablage kopiert!
The AMQ OpenWire JMS examples require a running message broker with a queue named exampleQueue. Use the procedures below to install and start the broker and define the queue.
C.1. Installing the broker Link kopierenLink in die Zwischenablage kopiert!
Follow the instructions in Getting Started with AMQ Broker to install the broker and create a broker instance. Enable anonymous access.
The following procedures refer to the location of the broker instance as <broker-instance-dir>.
C.2. Starting the broker Link kopierenLink in die Zwischenablage kopiert!
Procedure
Use the
artemis runcommand to start the broker.<broker-instance-dir>/bin/artemis run
$ <broker-instance-dir>/bin/artemis runCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the console output for any critical errors logged during startup. The broker logs
Server is now livewhen it is ready.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
C.3. Creating a queue Link kopierenLink in die Zwischenablage kopiert!
In a new terminal, use the artemis queue command to create a queue named exampleQueue.
<broker-instance-dir>/bin/artemis queue create --name exampleQueue --address exampleQueue --auto-create-address --anycast
$ <broker-instance-dir>/bin/artemis queue create --name exampleQueue --address exampleQueue --auto-create-address --anycast
You are prompted to answer a series of yes or no questions. Answer N for no to all of them.
Once the queue is created, the broker is ready for use with the example programs.
C.4. Stopping the broker Link kopierenLink in die Zwischenablage kopiert!
When you are done running the examples, use the artemis stop command to stop the broker.
<broker-instance-dir>/bin/artemis stop
$ <broker-instance-dir>/bin/artemis stop
Revised on 2020-06-16 17:55:28 UTC