WSO2 ESB has a good integration with ActiveMQ queueing platform.
We can have proxies that consume messages from a queue (or topic), call backend for processing or perform orchestration by calling several services and send response to a reply queue.
Environment
In this example, versions of ActiveMQ 5.13 and WSO2 ESB 4.9 are used.
In order WSO2 ESB to communicate with ActiveMQ, we need to:
- Copy the following client libraries from <AMQ_HOME>/lib directory to < ESB_HOME>/repository/components/lib
- activemq-broker-5.13.2
- activemq-client-5.13.2.jar
- geronimo-j2ee-management_1.1_spec-1.0.1
- geronimo-jms_1.1_spec-1.1.1
- hawtbuf-1.11
- Enable and configure JMSReceiver and JMSSender for Activemq in conf/axis2/axis2.xml
HTTP to JMS Dual Channel
HTTP -> JMS –orchectration– -> JMS reply
JMS Request Reply Endpoint
The endpoint has defined reply destination
JMSRequestReply_endpoint
HTTP to JMS Request and Reply proxy
This HTTP proxy sends message to JMS queue and waits for the response from JMS Reply queue.
The message is received from HTTP forwarded to JMS queue. Out sequence waits for he message from JMS reply queue and forwards it to HTTP Response.
HTTP_JMS_RequestReply
JMS Request Response proxy
This Proxy has JMS transport. It receives the message, processes it and sends reply message in the reply queue. In this proxy we can orchestrate calls to other services/systems, gather results and send resulting message to the reply queue. This message will be forwarder as HTTP response ij the previous proxy, named HTTP 2 JMS Request Reply. Message is transferred from the inSequence to the outSequence with loopback mediator. With payload mediator we can construct new reply message.
Information for receiver and reply queue is placed in the proxy as parameters.
Sending the message
In ActiveMQ web console we can see that the message is enqueued and consumed (dequeued)
HTTP to JMS Asynchronous Channel
For Asynchronous channel, we use property OUT_ONLY = true. The message is put to queue by http proxy but the response is not expected. The endpoint has no Reply queue specified.
JMS Endpoint
Http Sender to JMS queue
To test receiving JMS messages by ESB proxy, we might make helper proxy that will receive SOAP message from a web service (ex. From Soap UI) and send it to a queue.
The proxy is called HTTP_2_JMS_Send
SOAP Endpoint for this http proxy is http://localhost:8280/services/HTTP_2_JMS_Send
JMS Receive and Reply Proxy
jmsReceiveAndReply – This is the main proxy. It receives the message from the queue, processes it and sends reply to the reply destination.
Sending the message
In ActiveMQ web console we can see that the message is enqueued. (See Queue1 and Queue1Reply.)
Also in log, we can see log messages.
Conclusion
ActiveMQ has easy and reliable integration with WSO2 ESB. Their setup is straightforward and their runtime functioning is seamless. This blog is about necessary steps and jars for integration of ActivemQ and WSO2 ESB as well as HTTP <-> JMS communication as both protocols are used in enterprise environments. Placing message into a queue can be done easily with HTTP proxy that sends a message to a JMS queue. HTTP to JMS Dual Channel synchronous communication is shown as well as asynchronous communication in the later case.
If you have any questions about this blogpost contact us via the comments section of this blog. View also our WSO2 Tutorials, webinars or white papers for more technical information. Need support? We do deliver WSO2 Product Support, WSO2 Development Support, WSO2 Operational Support and WSO2 Training Programs.