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

Related

  • Advanced Error Handling and Retry Patterns in Enterprise REST Integrations
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 2
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 1
  • Event-Driven Pipelines With Apache Pulsar and Go

Trending

  • A System Cannot Protect What It Does Not Understand
  • Ujorm3: A New Lightweight ORM for JavaBeans and Records
  • Building an Image Classification Pipeline With Apache Camel and Deep Java Library (DJL)
  • Multi-Scale Feature Learning in CNN and U-Net Architectures
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. ActiveMQ Integration in Mule and Performance Tuning Techniques

ActiveMQ Integration in Mule and Performance Tuning Techniques

Learn how to integrate the ActiveMQ message broker with Mule, plus some tips on tuning ActiveMQ performance for better speed and efficiency.

By 
Rajesh Kumar user avatar
Rajesh Kumar
·
Nov. 15, 17 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
8.3K Views

Join the DZone community and get the full member experience.

Join For Free

ActiveMQ is one of the popular open source messaging providers. Mule is one of the most famous integration providers, which provides an ESB feature and framework to expose/create API mechanisms. Mule provides a connector to integrate easily with ActiveMQ and supports JMS 1.1 and J2SE 1.4 specifications.

Here, we will talk about the basic integration of ActiveMQ with Mule and performance tuning techniques. ActiveMQ configuration needs to be done using the JMS connector, which comes default in AnyPoint Studio.

Integration Steps

Drag and drop the JMS connector from the design palette in Anypoint Studio.

Image title

For connector configuration, use <jms:activemq-connector> or <jms:activemq-xa-connector> (to support XA transactions), like so:

<jms:activemq-connector name="jmsConnector"
                          brokerURL="tcp://localhost:61616"/>
  <jms:activemq-xa-connector name="jmsXAConnector"
                             brokerURL="tcp://localhost:61616"/>

Active MQ Connector Reference:

Click on "Connector configuration" and add the ActiveMQ information.

Image title

Refer to the documentation for more information on connector configuration.

Performance Tuning

When ActiveMQ message producer sends a non-persistent message (async publishing), it's dispatched asynchronously (fire then forget), but in the case of persistent messages, the publisher will block until it gets a notification that message has been processed by the broker.

Messages are dispatched with the delivery mode set to be persistent by default, so if you are sending messages on a topic, the publisher will block by default (even if there are no durable subscribers on the topic) until the broker has returned a notification.

So if you looking for good performance with topic messages, either set the delivery mode on the publisher to be non-persistent or set the "useAsyncsend" property on the ActiveMQ ConnectionFactory.

What Is the Preferred Pre-Fetch Size for Consumers?

ActiveMQ has the capability to push as many messages to the consumer as fast as possible, where they will be queued for processing by an ActiveMQ session. Here, pre-fetch configuration is very important based on the consumer.

The maximum number of messages that ActiveMQ will push to a consumer without the consumer processing a message is set by the pre-fetch size. It's very important to define the correct pre-fetch size for consumers, since during large volumes of transactions, there is a huge chance of messages piling up, which creates system failovers.

Default values - For Consumer type - queue - 1000 , queue- browser - 500, topic - 32767, durable topic - 1000.

Maven Integration

Mule supports Maven integration. Maven allows you to run performance tests easily using the Maven command line, or run tests automatically as part of your continuous integration.

Maven repo to run:


    <plugin>
    <groupId>org.apache.activemq.tooling</groupId>
    <artifactId>activemq-perf-maven-plugin</artifactId>
    <version>${activemq-version}</version>
    </plugin>

Maven Goals:

  • activemq-perf:consumer - Starts the consumer's performance testing. The generated report file can be found in the directory specified in the parameter "sysTest.reportDir."

  • activemq-perf:producer- Starts the producer's performance testing. The generated report file can be found in the directory specified in the parameter "sysTest.reportDir."

  • activemq-perf:broker - Starts broker using the activemq configuration file located in "src\main\resources\broker-conf" where the default config is activemq.xml.

Parameters: 

  • -DconfigType - specifies the type of configuration to use. Its value must be one of the -DconfigFile - path to config file other than those in "src\..\broker-config".e.g -DconfigFile=c:\dir\activemq.xml).

File-based persistence: Apache ActiveMQ supports a file-based persistence store that can be used to increase throughput for persistent messages. As part of configuration, set pre-acknowledge to true. With pre-acknowledge mode, messages are acknowledged before they are sent to the client; this will reduce the amount of acknowledgment traffic in the flow.  Disable the persistence if you don't need it; you get a good performance boost by disabling persistence.

Integration

Opinions expressed by DZone contributors are their own.

Related

  • Advanced Error Handling and Retry Patterns in Enterprise REST Integrations
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 2
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 1
  • Event-Driven Pipelines With Apache Pulsar and Go

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook