Categories: Mule 4Mulesoft

JMS Connector with Apache Activemq

JMS Connector – Mule 4

In this tutorial we will talk about how to use JMS connector with Apache ActiveMQ with various use cases and scenarios. Anypoint Connector for JMS (Java Message Service) (JMS Connector) enables sending and receiving messages to queues and topics for any message service that implements the JMS specification. JMS is a widely used API for message-oriented middleware. It enables the communication between different components of a distributed application to be loosely coupled, reliable, and asynchronous. The main features of JMS Connector include:

  • Publish and subscribe pattern support on any given destination
  • Listen and reply pattern support on any given destination
  • Publish and consume pattern support on any given destination, with a fixed or temporary reply queue
Prerequisite

We would need to download apache ActiveMQ from http://activemq.apache.org/download.html

ActiveMQ Set Up

Unzip the archive downloaded. You should be able to see following.

Run the command D:\Application\apache-activemq-5.15.2\bin>activemq start to start the ActiveMQ.

Open http://localhost:8161/admin/ and you should be able to see page below. use “admin“ as username and password.

Click on queue or topic to create a new queue or topic accordingly

Integration with MuleSoft

Perform the steps below for ActiveMQ connection configuration

  • Add the JMS config
  • Select “ActiveMQ Connection” in the connection parameter.
  • Now, you will need to add client jars to connect to Active MQ. Click on Configure to add the Client jars.

Dependency below would be added in POM.

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-client</artifactId>
    <version>5.14.5</version>
</dependency>

You would also need to add the dependency for ActiveMQ broker (for non persistent in memory connection) or ActiveMQ Kaha DB (for persistent connection). Click on configure Broker dependency.

Dependency below would be added in POM.

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-broker</artifactId>
    <version>5.15.4</version>
</dependency>
  • Enter the broker URL as tcp://localhost:61616 and test the connection. Test connection should be successful as below. if not then, check if your activeMQ is started properly or if the dependencies are loaded correctly.
Basic JMS operations

You can use JMS in your application to Send a message to queue or a topic using “Publish” JMS message processor.

Note: Also read about C Program – Structure & Keywords in C.

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Recent Posts

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago