3. Java Messaging Services
(JMS)
• A message oriented middleware
• Supports creation of message based
applications
• Supports loosely coupled middleware
• Supports transactions
• Supports reliability
4. JMS QUEUE
• Standard Queuing
• First In First Out (FIFO)
• Point to point i.e., single producer and
single consumer
• The behavior is similar to Mule VM
queues
5. JMS TOPIC
• Enables publish and subscribe mechanism
• The model is similar to RSS feed
• Multiple subscribers can subscribe to a topic
• Supports publishing a message even if subscriber
is disconnected using durable attribute in mule JMS
Message
Publisher
Message Subscriber
1
Message
Subscriber 2
Message Subscriber
N
6. JMS backchannel
• Backchannel allows response to be returned back in synchronous mule
message flow
• There are two ways to create backchannel in Mule
• Define your outbound endpoint with request-response exchange pattern
• Use a request-reply message processor
• Backchannel allows JMS endpoint to behave as two way channel
• It internally sets “reply-to” header that tells mule where to send a response
Client Server
Channel
Backchannel
Transport
7. MESSAGE FILTER IN JMS
• Mule supports selecting specific
messages at the consumers end by
using JMS selector
• JMS selector can use JMS header
properties
• Non matching messages remains in the
<jms:inbound-endpoint connector-ref="Active_MQ" doc:name="ActiveMQ"
topic="TestTopic">
<jms:selector expression="JMSPriority=5" />
</jms:inbound-endpoint>
8. JMS TRANSFORMERS IN MULE
• The default transformers applied to JMS endpoints are as
follows:
• inbound = JMSMessageToObject
• outbound = ObjectToJMSMessage
• response = ObjectToJMSMessage
• The transformation happens to/from as given below
JMS Type Java Type
javax.jms.TextMessage java.lang.String
javax.jms.ObjectMessage java.lang.Object
javax.jms.BytesMessage byte[]
javax.jms.MapMessage java.util.Map
javax.jms.StreamMessage java.io.InputStream
9. EXAMPLE CONFIGURATION FOR
ACTIVE MQ
• Configuring a JMS connector using
ActiveMQ
• Defining JMS outbound endpoint
• Defining JMS inbound endpoint
• The example configuration for JMS
connector and inbound/outbound
endpoints are given in coming slides and
configuration is using a JMS topic
10. CONFIGURING A JMS CONNECTOR USING
ACTIVE MQ
<jms:activemq-connector name="Active_MQ" specification="1.1"
username="username" password="password" brokerURL="tcp://host:port"
validateConnections="true" doc:name="Active MQ"/>