Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
5.4. Tutorial I: JAAS Authentication
Overview Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
This tutorial shows you how to communicate with the AMQ broker using example producer and consumer JMS clients. The JMS clients must first be modified, however, to provide the requisite username/password JMS credentials.
Prerequisites Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following prerequisites are needed for this tutorial:
- Apache Ant—Apache Ant is a free, open source build tool from Apache. You can download the latest version from http://ant.apache.org/bindownload.cgi (minimum is 1.8).
- Apache ActiveMQ installation—the standalone installation of Apache ActiveMQ has some demonstration code that is not available in Red Hat AMQ. The Apache ActiveMQ distribution is provided in the
InstallDir/extras
directory in an archive format. Uncompress and extract the archive to a convenient installation location,ActiveMQInstallDir
.
Tutorial steps Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To test the example JMS clients with AMQ, perform the following steps:
Install the consumer and producer JMS clients Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The Apache ActiveMQ distribution is provided in the
InstallDir/extras
directory in an archive format. Uncompress and extract the archive to a convenient installation location, ActiveMQInstallDir
(the consumer and producer clients can be accessed by running ant
targets under the ActiveMQInstallDir/examples/openwire/swissarmy
directory).
Customize the users.properties file Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The
karaf
JAAS realm can be administered by editing the InstallDir/etc/users.properties
file, where the file contains entries in the following format:
Username=Password,Role1,Role2,...
Username=Password,Role1,Role2,...
For example, the default
users.properties
file shows a sample entry (which is commented out) for the user, admin
, with password, admin
, as follows:
#admin=admin,admin
#admin=admin,admin
Customize the
users.properties
file by adding at least one user entry with the Administrator
role. For example:
Username=Password,Administrator
Username=Password,Administrator
Start the container Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Change directory to
InstallDir/bin
and enter the following command:
./amq
./amq
Run the consumer with JMS credentials Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To connect the consumer tool to the
tcp://localhost:61616
endpoint, change directory to ActiveMQInstallDir/examples/openwire/swissarmy
and enter the following command:
ant consumer -Duser=admin -Dpassword=admin -Durl=tcp://localhost:61616 -Dmax=100
ant consumer -Duser=admin -Dpassword=admin -Durl=tcp://localhost:61616 -Dmax=100
You should see some output like the following:
Run the producer with JMS credentials Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To connect the producer tool to the
tcp://localhost:61616
endpoint, open a new command prompt, change directory to ActiveMQInstallDir/examples/openwire/swissarmy
and enter the following command:
ant producer -Duser=admin -Dpassword=admin -Durl=tcp://localhost:61616 -Dmax=100
ant producer -Duser=admin -Dpassword=admin -Durl=tcp://localhost:61616 -Dmax=100
In the window where the consumer tool is running, you should see some output like the following:
[java] [Thread-2] Received: 'Message: 0 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 1 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 2 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 3 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 4 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000)
[java] [Thread-2] Received: 'Message: 0 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000)
[java] [Thread-2] Received: 'Message: 1 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000)
[java] [Thread-2] Received: 'Message: 2 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000)
[java] [Thread-2] Received: 'Message: 3 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000)
[java] [Thread-2] Received: 'Message: 4 sent at: Mon Mar 18 17:12:16 CET 2013 ...' (length 1000)