DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Configuring a Shopify MuleSoft Connector
  • Handle HL7 MLLP Messages With Mule 4
  • SharePoint Integration With MuleSoft
  • Configuring Amazon S3 Using Mulesoft

Trending

  • Apache Doris and DeepSeek: Redefining Intelligent Data Analytics
  • From OCR Bottlenecks to Structured Understanding
  • Beyond Java Streams: Exploring Alternative Functional Programming Approaches in Java
  • MCP Client Agent: Architecture and Implementation
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Anypoint JMS Connector With Mulesoft

Anypoint JMS Connector With Mulesoft

When you work with the Anypoint JMS Connector in Mulesoft, you can enable one-to-one communication, deliver messages to a variety of receivers, and more.

By 
Jitendra Bafna user avatar
Jitendra Bafna
DZone Core CORE ·
Updated May. 15, 17 · Tutorial
Likes (10)
Comment
Save
Tweet
Share
37.5K Views

Join the DZone community and get the full member experience.

Join For Free

JMS (Java Messaging Service) is mostly used with APIs, enabling the application to communicate through the exchange of messages. JMS connector is capable of sending and receiving messages to and from topics and queues.

JMS supports two models for messaging:

  1. Queue (point to point).

  2. Topic (publish-subscribe).

Queue

  • It enables one-to-one communication. It is also called point-to-point communication.

  • The sender will deliver a message to the queue and single receivers will pick the message from the queue.

  • The receiver doesn't need to listen to queue at the time when the message is sent to the queue.

Topic

  • It enables one-to-many communication. It is also called publish-subscribe communication.

  • The publisher will deliver the message to a topic and it will be received by all subscribers who are actively listening to the topic.

  • A subscriber will miss the published message if it is not actively listening to the topic unless messages are made durable.

We will walk through how to use Anypoint JMS Connector for receiving and sending messages to a topic.

JMS Connector for Publishing Message to Topic

Place a JMS connector at the Message Source section in Mule Flow.

Configure the connector properties like Display Name and Topic and click Add Connector Configuration. This will open another window. Select the JMS of your choice. In this case, we will select ActiveMQ and press OK.

Image titleAfter clicking OK, it will open another window where you need to provide your Broker URL and username/password if applicable.

Image title

Now, you need to add the ActiveMQ JAR file in your project. Drag and Drop the jar file (i.e., activemq-all-5.6.0.jar) into your project, go to the Package Explorer pane, and right click then select Build Path > Add to Build Path.

Image title

Image title

<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="jmsconnectorFlow">
<jms:inbound-endpoint topic="test" connector-ref="Active_MQ" doc:name="JMS"/>
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="src/test/resources" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>

This is how you can configure your JMS topic for publishing messages to ActiveMQ.

JMS Connector for Subscribing Message from Topic

Place the JMS connector at the middle or end of the flow (basically, in the Message Processor region).

Configure JMS Connector in the same way as we have done for Publishing the message to the topic. You need to add the Active MQ JAR file for subscribing the message to the topic, as has been explained above.

Image title

<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="jmsconnectorFlow">
<file:inbound-endpoint path="src/test/resources" responseTimeout="10000" doc:name="File"/>
<logger level="INFO" doc:name="Logger"/>
<jms:outbound-endpoint topic="test" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
</mule>

This is how you can configure your JMS Topic for subscribing message from ActiveMQ.

Supported JMS Providers

  • Out-of-box support for ActiveMQ, WebLogic JMS, Generic, or any custom JMS.

  • Hornet MQ, Open MQ, Solace JMS,  Tibco EMS.

  • WebSphere MQ.

Now, you know how to subscribe and publish message to and from JMS topics!

Here is the video tutorial:


Connector (mathematics) MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Configuring a Shopify MuleSoft Connector
  • Handle HL7 MLLP Messages With Mule 4
  • SharePoint Integration With MuleSoft
  • Configuring Amazon S3 Using Mulesoft

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: