@sureshFirst of all, you need to make sure you are on the correct version of Apigee Edge on-premise installation. JMS feature is available in 1504 and 1504_ws.
Coming to the actual implementation and how it works, here you go:
The router behaves like a consumer of JMS messages and can subscribe to a queue for a JMS provider like ActiveMQ. For this to work, you need to have the activeMQ client libraries installed in the router. You need the following jars:
1. Go to the third-party lib folder:
cd /opt/apiged4/share/lib/thirdparty
2. Download JMS Client Libraries:
sudo wget [http://repo1.maven.org/maven2/org/apache/activemq/activemq-client/5.8.0/activemq-client-5.8.0.jar](http://repo1.maven.org/maven2/org/apache/activemq/activemq-client/5.8.0/activemq-client-5.8.0.jar)
sudo wget [http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-j2ee-management_1.1_spec/1.0.1/geronimo-j2ee-management_1.1_spec-1.0.1.jar](http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-j2ee-management_1.1_spec/1.0.1/geronimo-j2ee-management_1.1_spec-1.0.1.jar)
sudo wget [http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar](http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar)
sudo wget [http://repo1.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.2/hawtbuf-1.2.jar](http://repo1.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.2/hawtbuf-1.2.jar)
3. Change the file owner and permissions:
sudo chown apigee geronimo-jms_1.1_spec-1.1.1.jar
sudo chown apigee geronimo-j2ee-management_1.1_spec-1.0.1.jar
sudo chown apigee hawtbuf-1.2.jar
sudo chown apigee activemq-client-5.8.0.jar
sudo chmod +x geronimo-jms_1.1_spec-1.1.1.jar
sudo chmod +x geronimo-j2ee-management_1.1_spec-1.0.1.jar
sudo chmod +x hawtbuf-1.2.jar
sudo chmod +x activemq-client-5.8.0.jar
Once this is done, you need to restart the router. This makes sure the router is now ready to act as a consumer of JMS messages. The router uses the client libraries to create a subscription to the destination queue using JNDI.
Next we need to create a jmsHost and create an api proxy that can be deployed to this jmsHost. Once the proxy is deployed, the router subscribes to the queue (mentioned in the jmsHost) and starts picking up messages from the queue. The router picks up these messages, converts them into an equivalent HTTP message (jms headers are converted into http headers, jms message is sent as an http message) and sends it to the message processor like any other http message. From here on in, the normal api proxy flow starts and you can apply all the policies and rules that you could apply for a standard http proxy. On the response flow, once the message processor has completed the response flow, it sends back the response to the router. The router now does a reverse operation and converts the http message into a jms message and writes back to a replyQueue, as specified in the jmsHost.
Now let’s take an example:
Step 1: Create a jmsHost:
POST /v1/organizations/{org}/environments/{env}/jmshosts
<?xml version="1.0" encoding="UTF-8"?>
<JMSHost name="jmsHost">
<Description>Sample JMS Host</Description>
<ConnectionFactoryClass>org.apache.activemq.jndi.Active</ConnectionFactoryClass>
<ConnectionFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</ConnectionFactory>
<ConnectionURL>{activemqConnectionURL}</ConnectionURL>
<Context>ConnectionFactory</Context>
<ContextUsername>somebody</ContextUsername>
<ContextPassword>somepassword</ContextPassword>
<ConnectionUsername>admin</ConnectionUsername>
<ConnectionPassword>password</ConnectionPassword>
<Connections>5</Connections>
</JMSHost>
Step 2: Create a jms proxy:
Refer to the attached jmsapi.zip. It has a httpProxy endpoint and multiple jmsProxy endpoint with different subscriptions - different destination queue or message selector etc. An example jmsProxy endpoint is below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint proxyType="jmsConnection" name="jmsProxyEndpointDifferentQueue">
<Description/>
<FaultRules/>
<Flows/>
<JmsProxyConnection>
<Destination>dynamicQueues/sourceAppsDataQ</Destination>
<JmsHost>jmsHost</JmsHost>
<MessageSelector>JMSType='apps'</MessageSelector>
<MessageSelector>JMSType='data'</MessageSelector>
</JmsProxyConnection>
<RouteRule name="default">
<TargetEndpoint>jmsTarget</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
Note that MessageSelector is option, you can simply provide a JmsProxyConnection with the Destination and JmsHost entities.
Step 3: Deploy the proxy.
Once you deploy the proxy, you should see messages being consumed from your acitveMQ queues by this proxy. You would also see consumers created and listening on respective queues, depending on how your proxy is configured. You can use the activeMQ admin console to see the list of subscribers and the messages enqueued and dequeued.
I hope this helps you resolve your query. Kindly accept my answer if it does. You can find more details here