Miyuru Wanninayaka 
Senior Technical Lead 
Isuru Ranawaka 
Software Engineer 
Sep 24 2014 
Understanding 
JMS Integration Patterns
About the Presenters 
๏ Miyuru Wanninayaka - miyuru@wso2.com 
Miyuru is a Senior Technical Lead in the integration technologies team where he mainly 
focuses on the WSO2 Enterprise Service Bus. In addition to his product development efforts, 
he has provided technology consulting on customer engagements, helping to successfully 
implement enterprise integration and mobile services gateway solutions 
๏ Isuru Ranawaka - Isurur@wso2.com 
Isuru is a Software Engineer at WSO2. Previously an intern at WSO2 in 2012, Isuru worked on 
developing CEP artifact creater tool for WSO2 Developer Studio and enhancing performance 
of Siddhi CEP engine. He is a graduate from the Department of Computer Science and 
Engineering, University of Moratuwa. Isuru worked on developing distributed CEP as his final 
year project.
About WSO2 
๏ Global enterprise, founded in 2005 by 
acknowledged leaders in XML, web 
services technologies, standards and 
open source 
๏ Provides only open source platform-as-a-service 
for private, public and hybrid cloud 
deployments 
๏ All WSO2 products are 100% open source 
and released under the Apache License 
Version 2.0. 
๏ Is an Active Member of OASIS, Cloud 
Security Alliance, OSGi Alliance, AMQP 
Working Group, OpenID Foundation and 
W3C. 
๏ Driven by Innovation 
๏ Launched first open source API 
Management solution in 2012 
๏ Launched App Factory in 2Q 2013 
๏ Launched Enterprise Store and first 
open source Mobile solution in 4Q 2013
What WSO2 delivers
Agenda 
๏ JMS 
๏ WSO2 Message Broker 
๏ Configuring JMS Transport of WSO2 ESB 
๏ JMS Patterns with WSO2 ESB 
๏ Beyond JMS
* 
Introducing WSO2 ESB 
๏ A lightweight, high performance ESB 
๏ Comprehensive REST, SOAP, WS-* support 
๏ 100% compliant with all EIPs (Enterprise Integration 
Patterns) 
๏ Connectors (Salesforce, Twilio and many more) 
๏ SAP, FIX, HL7 - Domain specific solutions 
๏ Zero Code/Configuration driven 
๏ Extensible and Scalable
Messaging with MOM 
๏ Messaging enables distributed communication that is loosely 
coupled 
๏ Sender does not need to know about the receiver, nor does the 
receiver know anything about the sender
What is Java Message Service 
(API) 
๏ Is an API that allows applications to create, send, receive, and 
read messages 
๏ Enables communication that is 
๏ Loosely coupled 
๏ Asynchronous - JMS provider can deliver messages as they 
arrive, client does not have to request messages. 
๏ Reliable - The JMS API ensures that a message is delivered 
once and only once
JMS Terminology
Message Producer, Consumer 
and Broker 
Message 
Producer 
dest = (Destination) jndiContext.lookup(destName); 
queue = (Queue) jndiContext.lookup(queueName); 
MessageProducer producer = session.createProducer(dest); 
TextMessage message = session.createTextMessage(); 
message.setText(“Hello”); 
producer.send(message); 
Message 
Consumer 
Message 
Broker 
dest = (Destination) jndiContext.lookup(destName); 
queue = (Queue) jndiContext.lookup(queueName); 
MessageConsumer consumer = session.createConsumer(dest); 
Message m = consumer.receive();
Queue 
๏ Facilitates users to store messages sent by an external party, in 
an intermediate location and access them on-demand 
๏ Enables users to publish messages and receive them in the order 
that they are sent 
๏ Natively persistent 
๏ Even after shutting down the server or if a sudden crash 
happens, messages still remain in the queue ready to be 
delivered
Topic 
๏ Every message is delivered to all the subscribers 
๏ Non persistent unless durable subscription
What is WSO2 Message Broker? 
๏ WSO2 MB is a message brokering system based on Java 
Messaging Service (JMS). 
๏ Any client that supports AMQP is able to communicate with 
WSO2 Message Broker 
๏ Can be used as a standalone message broker or a distributed 
message brokering system. 
๏ Uses Apache Cassandra as its message store and Apache 
Zookeeper for distributed coordination 
๏ Can put message to one MB node in the cluster and pick up the 
message from another node MB
Configuring JMS transport of 
WSO2 ESB 
๏ Enable JMS transport sender and receiver in axis2.xml 
๏ Copy JMS client libraries provided by JMS broker to [ESB_HOME] 
/repository/components/lib 
๏ https://docs.wso2.org/display/ESB481/Configuring+JMS+Transport 
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> 
<parameter name="myTopicConnectionFactory" locked="false"> 
<parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> 
<parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> 
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter> 
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter> 
</parameter> 
<parameter name="myQueueConnectionFactory" locked="false"> 
<parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> 
<parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> 
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> 
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> 
</parameter> 
<parameter name="default" locked="false"> 
<parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> 
<parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> 
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> 
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> 
</parameter> 
</transportReceiver>
Patterns with JMS
ESB as JMS Consumer 
๏ ESB listens to a JMS queue 
๏ JMS client can place a message in JMS queue 
๏ ESB picks message from JMS queue and process further 
๏ ESB does not need to be active/running to client to produce 
messages
ESB as JMS Producer 
๏ Client sends a message to ESB using synchronous transport like 
(HTTP) 
๏ ESB puts message to a JMS queue and ack to HTTT client 
๏ JMS consumer ( backend ) listens to JMS queue and picks 
message 
๏ ESB can produce messages to backend regardless of it’s active or 
not
ESB as both JMS Consumer and 
Producer 
๏ Combination of previous two patterns 
๏ Both ESB and Backend can go offline without breaking message 
flow
JMS Synchronous Invocations 
๏ Client sends a message to ESB using a synchronous transport 
(HTTP) 
๏ ESB sends a JMS message to request queue with JMSReplyTo 
header set to response queue 
๏ Backend reads message from request queue and place response 
to response queue (by checking JMSReplyTo header) 
๏ JMS correlation ID of response = message ID of request
JMS Synchronous Invocations 
๏ ESB picks matching response from response queue by reading 
JMS message which has correct correlation ID (ESB uses a JMS 
message selector to perform this) 
๏ Finally response if forwarded back to client 
๏ http://docs.oracle.com/cd/E19798-01/821-1841/bncer/index. 
html
JMS Synchronous Invocations 
(Quad Channel) 
๏ Using synchronous JMS invocations in both client and server side 
๏ Using synchronous JMS are NOT encouraged because it’s no 
longer time decoupled
Publish Subscribe with JMS 
Client ESB 
Topic 
๏ Subscribers subscribed to topic in JMS broker 
๏ Client sends a message to ESB 
๏ ESB forwards message to topic 
๏ Message broker delivers message to all subscribers 
Subscriber 
Subscriber 
Subscriber
Publish Subscribe Multiple ESBs 
Client ESB 
Topic 
ESB 
ESB 
ESB 
๏ Multiple ESB nodes subscribed to topic in JMS broker 
๏ Client sends a message to ESB 
๏ ESB forwards message to topic 
๏ Message broker delivers message subscribed ESB nodes
Message Store and Processor 
๏ JMS Message Store 
๏ Intermediate persistent storage of messages 
๏ A store works with a processor 
๏ Message Processor 
๏ Sampling processor 
๏ Message Forwarding processor 
๏ Provides store and forward messaging within the ESB 
๏ Can be used to implement 
๏ Guaranteed Delivery, Request Rate Matching, In Order 
Delivery, and Separation of Concerns
Message Store and Processor 
Matching Request Rates 
๏ Client and Service have two different/varying rate limits for 
sending and accepting messages respectively 
๏ ESB does rate matching 
๏ JMS message store provides Storage
Message Store and Processor 
Guaranteed Delivery 
๏ JMS message store acting as a Dead Letter Channel
Message Store and Processor 
In-Order Delivery 
(3) Send/Retry on 
failure 
๏ JMS message store acting as a FIFO Queue
Message Store and Processor 
Separation of Concerns 
๏ Most common use of a message store
Inbound Endpoint with 
Upcoming WSO2 ESB 4.9.0 
๏ Create JMS Listeners dynamically without changing axis2.xml and 
server restart 
๏ Support JMS protocol in tenants 
๏ Distributed coordination 
๏ Run in all/one node
MQTT 
๏ MQTT is light weight publish/subscribe protocol 
๏ Ideal for mobile devices/IoT because of small footprint 
๏ Latest WSO2 ESB supports connecting to MQTT broker 
๏ Upcoming WSO2 MB can act as a MQTT broker
Apache Kafka 
๏ Distributed publish-subscribe messaging system 
๏ WSO2 ESB 4.9.0 will support connecting to Apache Kafka 
๏ Kafka Inbound endpoint ( consumer ) 
๏ Kafka Connector ( producer )
* 
๏ WSO2 ESB 
http://wso2.com/products/enterprise-service-bus 
๏ WSO2 ESB Documentation 
https://docs.wso2. 
org/display/ESB481/WSO2+Enterprise+Service+Bus+Documentation 
6 
Links
* 
Business Model
Contact us !

Understanding JMS Integration Patterns

  • 1.
    Miyuru Wanninayaka SeniorTechnical Lead Isuru Ranawaka Software Engineer Sep 24 2014 Understanding JMS Integration Patterns
  • 2.
    About the Presenters ๏ Miyuru Wanninayaka - miyuru@wso2.com Miyuru is a Senior Technical Lead in the integration technologies team where he mainly focuses on the WSO2 Enterprise Service Bus. In addition to his product development efforts, he has provided technology consulting on customer engagements, helping to successfully implement enterprise integration and mobile services gateway solutions ๏ Isuru Ranawaka - Isurur@wso2.com Isuru is a Software Engineer at WSO2. Previously an intern at WSO2 in 2012, Isuru worked on developing CEP artifact creater tool for WSO2 Developer Studio and enhancing performance of Siddhi CEP engine. He is a graduate from the Department of Computer Science and Engineering, University of Moratuwa. Isuru worked on developing distributed CEP as his final year project.
  • 3.
    About WSO2 ๏Global enterprise, founded in 2005 by acknowledged leaders in XML, web services technologies, standards and open source ๏ Provides only open source platform-as-a-service for private, public and hybrid cloud deployments ๏ All WSO2 products are 100% open source and released under the Apache License Version 2.0. ๏ Is an Active Member of OASIS, Cloud Security Alliance, OSGi Alliance, AMQP Working Group, OpenID Foundation and W3C. ๏ Driven by Innovation ๏ Launched first open source API Management solution in 2012 ๏ Launched App Factory in 2Q 2013 ๏ Launched Enterprise Store and first open source Mobile solution in 4Q 2013
  • 4.
  • 5.
    Agenda ๏ JMS ๏ WSO2 Message Broker ๏ Configuring JMS Transport of WSO2 ESB ๏ JMS Patterns with WSO2 ESB ๏ Beyond JMS
  • 6.
    * Introducing WSO2ESB ๏ A lightweight, high performance ESB ๏ Comprehensive REST, SOAP, WS-* support ๏ 100% compliant with all EIPs (Enterprise Integration Patterns) ๏ Connectors (Salesforce, Twilio and many more) ๏ SAP, FIX, HL7 - Domain specific solutions ๏ Zero Code/Configuration driven ๏ Extensible and Scalable
  • 7.
    Messaging with MOM ๏ Messaging enables distributed communication that is loosely coupled ๏ Sender does not need to know about the receiver, nor does the receiver know anything about the sender
  • 8.
    What is JavaMessage Service (API) ๏ Is an API that allows applications to create, send, receive, and read messages ๏ Enables communication that is ๏ Loosely coupled ๏ Asynchronous - JMS provider can deliver messages as they arrive, client does not have to request messages. ๏ Reliable - The JMS API ensures that a message is delivered once and only once
  • 9.
  • 10.
    Message Producer, Consumer and Broker Message Producer dest = (Destination) jndiContext.lookup(destName); queue = (Queue) jndiContext.lookup(queueName); MessageProducer producer = session.createProducer(dest); TextMessage message = session.createTextMessage(); message.setText(“Hello”); producer.send(message); Message Consumer Message Broker dest = (Destination) jndiContext.lookup(destName); queue = (Queue) jndiContext.lookup(queueName); MessageConsumer consumer = session.createConsumer(dest); Message m = consumer.receive();
  • 11.
    Queue ๏ Facilitatesusers to store messages sent by an external party, in an intermediate location and access them on-demand ๏ Enables users to publish messages and receive them in the order that they are sent ๏ Natively persistent ๏ Even after shutting down the server or if a sudden crash happens, messages still remain in the queue ready to be delivered
  • 12.
    Topic ๏ Everymessage is delivered to all the subscribers ๏ Non persistent unless durable subscription
  • 13.
    What is WSO2Message Broker? ๏ WSO2 MB is a message brokering system based on Java Messaging Service (JMS). ๏ Any client that supports AMQP is able to communicate with WSO2 Message Broker ๏ Can be used as a standalone message broker or a distributed message brokering system. ๏ Uses Apache Cassandra as its message store and Apache Zookeeper for distributed coordination ๏ Can put message to one MB node in the cluster and pick up the message from another node MB
  • 14.
    Configuring JMS transportof WSO2 ESB ๏ Enable JMS transport sender and receiver in axis2.xml ๏ Copy JMS client libraries provided by JMS broker to [ESB_HOME] /repository/components/lib ๏ https://docs.wso2.org/display/ESB481/Configuring+JMS+Transport <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> <parameter name="myTopicConnectionFactory" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter> </parameter> <parameter name="myQueueConnectionFactory" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter> <parameter name="default" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter> </transportReceiver>
  • 15.
  • 16.
    ESB as JMSConsumer ๏ ESB listens to a JMS queue ๏ JMS client can place a message in JMS queue ๏ ESB picks message from JMS queue and process further ๏ ESB does not need to be active/running to client to produce messages
  • 17.
    ESB as JMSProducer ๏ Client sends a message to ESB using synchronous transport like (HTTP) ๏ ESB puts message to a JMS queue and ack to HTTT client ๏ JMS consumer ( backend ) listens to JMS queue and picks message ๏ ESB can produce messages to backend regardless of it’s active or not
  • 18.
    ESB as bothJMS Consumer and Producer ๏ Combination of previous two patterns ๏ Both ESB and Backend can go offline without breaking message flow
  • 19.
    JMS Synchronous Invocations ๏ Client sends a message to ESB using a synchronous transport (HTTP) ๏ ESB sends a JMS message to request queue with JMSReplyTo header set to response queue ๏ Backend reads message from request queue and place response to response queue (by checking JMSReplyTo header) ๏ JMS correlation ID of response = message ID of request
  • 20.
    JMS Synchronous Invocations ๏ ESB picks matching response from response queue by reading JMS message which has correct correlation ID (ESB uses a JMS message selector to perform this) ๏ Finally response if forwarded back to client ๏ http://docs.oracle.com/cd/E19798-01/821-1841/bncer/index. html
  • 21.
    JMS Synchronous Invocations (Quad Channel) ๏ Using synchronous JMS invocations in both client and server side ๏ Using synchronous JMS are NOT encouraged because it’s no longer time decoupled
  • 22.
    Publish Subscribe withJMS Client ESB Topic ๏ Subscribers subscribed to topic in JMS broker ๏ Client sends a message to ESB ๏ ESB forwards message to topic ๏ Message broker delivers message to all subscribers Subscriber Subscriber Subscriber
  • 23.
    Publish Subscribe MultipleESBs Client ESB Topic ESB ESB ESB ๏ Multiple ESB nodes subscribed to topic in JMS broker ๏ Client sends a message to ESB ๏ ESB forwards message to topic ๏ Message broker delivers message subscribed ESB nodes
  • 24.
    Message Store andProcessor ๏ JMS Message Store ๏ Intermediate persistent storage of messages ๏ A store works with a processor ๏ Message Processor ๏ Sampling processor ๏ Message Forwarding processor ๏ Provides store and forward messaging within the ESB ๏ Can be used to implement ๏ Guaranteed Delivery, Request Rate Matching, In Order Delivery, and Separation of Concerns
  • 25.
    Message Store andProcessor Matching Request Rates ๏ Client and Service have two different/varying rate limits for sending and accepting messages respectively ๏ ESB does rate matching ๏ JMS message store provides Storage
  • 26.
    Message Store andProcessor Guaranteed Delivery ๏ JMS message store acting as a Dead Letter Channel
  • 27.
    Message Store andProcessor In-Order Delivery (3) Send/Retry on failure ๏ JMS message store acting as a FIFO Queue
  • 28.
    Message Store andProcessor Separation of Concerns ๏ Most common use of a message store
  • 29.
    Inbound Endpoint with Upcoming WSO2 ESB 4.9.0 ๏ Create JMS Listeners dynamically without changing axis2.xml and server restart ๏ Support JMS protocol in tenants ๏ Distributed coordination ๏ Run in all/one node
  • 30.
    MQTT ๏ MQTTis light weight publish/subscribe protocol ๏ Ideal for mobile devices/IoT because of small footprint ๏ Latest WSO2 ESB supports connecting to MQTT broker ๏ Upcoming WSO2 MB can act as a MQTT broker
  • 31.
    Apache Kafka ๏Distributed publish-subscribe messaging system ๏ WSO2 ESB 4.9.0 will support connecting to Apache Kafka ๏ Kafka Inbound endpoint ( consumer ) ๏ Kafka Connector ( producer )
  • 32.
    * ๏ WSO2ESB http://wso2.com/products/enterprise-service-bus ๏ WSO2 ESB Documentation https://docs.wso2. org/display/ESB481/WSO2+Enterprise+Service+Bus+Documentation 6 Links
  • 33.
  • 34.