Universal Messaging Developer Guide : Enterprise APIs : Enterprise Developer's Guide for Java : Code Examples : Provider for JMS : Using the AMQP Protocol
Using the AMQP Protocol
The JMS sample applications (with the exception of the JMS Queue Browser) can be used over the Advanced Message Queuing Protocol (AMQP) protocol. AMQP is defined by the ISO/IEC 19464 standard.
In order to switch to AMQP, you need to change the following environment variables, prior to running the JMS sample application:
Environment variable
Description
CONTEXT_FACTORY
The name of the ContextFactory class used by the sample application (default: com.pcbsys.nirvana.nSpace.NirvanaContextFactory). When using an AMQP connection this should be changed to:
*org.apache.qpid.jms.jndi.JmsInitialContextFactory - to use the QPID Proton JMS Client libraries, or
*org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory - to use the QPID Legacy JMS Client libraries
PROVIDER_URL
The URL of your local nirvana realm from which JNDI entries will be looked up (default: nsp://localhost:9000). When using an AMQP connection this should be changed to:
*amqp://localhost:9000 - when using a plain AMQP connection, connecting to a standard nsp interface;
*amqps://localhost:9000 - when using a plain AMQP connection over a secure socket connection, connecting to a nsps interface.
Note:  
AMQP connections require the AMQP plugin to be enabled on the realm and work only over the nsp and nsps interfaces. The connections will not work over nhp or nhps.
Note:  
When using AMQP with all JMS sample applications, the <factoryname> parameter is ignored, but it is still required. This is due to the internal implementation of the client libraries.
Plain AMQP pub/sub example
The following example assumes that you have an existing topic MyTopic configured on the realm server and bound in the JNDI context, and that the client tries to connect to a NSP interface.
To start a subscriber:
1. Start a "Java examples" command prompt
2. Set the following environment variables:

set CONTEXT_FACTORY=org.apache.qpid.jms.jndi.JmsInitialContextFactory
set PROVIDER_URL=amqp://<hostname>:<port>
3. Start the jmssub application by running the following command:
jmssub ignored topic.MyTopic
At this point the jmssub application will be running over AMQP and will receive any messages published on the MyTopic topic
To start a publisher:
1. Start a "Java examples" command prompt
2. Set the following environment variables:

set CONTEXT_FACTORY=org.apache.qpid.jms.jndi.JmsInitialContextFactory
set PROVIDER_URL=amqp://<hostname>:<port>
3. Start the jmssub application by running the following command:
jmspub ignored topic.MyTopic 10
At this point the jmspub application will be running over AMQP and will send 10 messages to the MyTopic topic.
AMQP over alternative TLS example
The following example assumes that you have an existing topic MyTopic configured on the realm server and bound in the JNDI context and that the client tries to connect to a NSPS interface.
To start a subscriber:
1. Start a "Java examples" command prompt
2. Set the following environment variables:
set CONTEXT_FACTORY=org.apache.qpid.jms.jndi.JmsInitialContextFactory
set PROVIDER_URL=amqps://<hostname>:<port>
3. Start the jmssub application by running the following command:
jmssub ignored topic.MyTopic
At this point the jmssub application will be running over AMQP and will receive any messages published on the MyTopic topic
To start a publisher:
1. Start a "Java examples" command prompt
2. Set the following environment variables:
set CONTEXT_FACTORY=org.apache.qpid.jms.jndi.JmsInitialContextFactory
set PROVIDER_URL=amqps://<hostname>:<port>
3. Start the jmssub application by running the following command:
jmspub ignored topic.MyTopic 10
At this point the jmspub application will be running over AMQP and will send 10 messages to the MyTopic topic.
Note:  
If the NSPS interface on the realm has been configured to use the certificates generated by the "CertificateGenerator" then you don't need to make any changes to the client applications. However if you are using different certificates, then in each command prompt, you need to additionally set the certificate locations by executing the following set commands:
set CAKEYSTORE=<TRUST KEYSTORE PATH>
set CAKEYSTOREPASSWD=<TRUST KEYSTORE PASSWORD>
set CKEYSTORE=<CLIENT KEYSTORE PATH>
set CKEYSTOREPASSWD=<CLIENT KEYSTORE PASSWORD>
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback