Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Message broker integration made simple with Red Hat Fuse

January 8, 2021
Francesco Marchioni
Related topics:
JavaSpring BootEvent-driven

    This article presents a sample integration between Red Hat AMQ 7 and IBM MQ, using Red Hat Fuse 7 for the integration. Traditionally, developers have used resource adapters for message bridging with external systems. A resource adapter is a system library that provides connectivity to an enterprise information system (EIS). Similar to how a Java Database Connectivity (JDBC) driver provides connectivity to a database management system, a resource adapter plugs into an application server such as Red Hat JBoss Enterprise Application Platform (JBoss EAP). It then connects the application server, enterprise information system, and the enterprise application.

    Resource adapters work well, but the configuration can be overwhelming, especially for scenarios that require adding numerous modules on top of the application server or where the resource adapter contract requires extensive administrative resources. Some scenarios require configuring multiple resource adapters and then arranging the message exchange between them.

    Red Hat Fuse provides a simpler, more flexible pattern for routing messages between components. Fuse leverages Apache Camel's JMS component to exchange messages via a Java Message Service (JMS) queue or topic. It relies on Spring’s JMS support for declarative transactions.

    Follow the demonstration in the next sections to see for yourself how the JMS component works in a Red Hat Fuse integration.

    Set up the Red Hat Fuse project

    For this demonstration, we will create a Spring Boot-based Fuse application that uses a Camel route to exchange messages between Red Hat AMQ and IBM MQ. To start, open a shell prompt and enter the following mvn command:

    mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \
    -DarchetypeCatalog=https://maven.repository.redhat.com/ga/io/fabric8/archetypes/archetypes-catalog/2.2.0.fuse-760024-redhat-00001/archetypes-catalog-2.2.0.fuse-760024-redhat-00001-archetype-catalog.xml \
    -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \
    -DarchetypeArtifactId=spring-boot-camel-xml-archetype \
    -DarchetypeVersion=2.2.0.fuse-760024-redhat-00001
    

    This command creates the basic project structure, including the Application class:

    package com.sample;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
    }
    

    So far, the code should look familiar.

    Configure the brokers

    Next, we'll configure the two brokers. Start by adding a @Configuration bean that contains the following JmsComponent bean declarations (note that the declarations are bound as @Bean using the method name for the id):

    package com.sample;
    
    import com.ibm.mq.jms.*;
    import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
    import org.apache.camel.component.jms.JmsComponent;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter;
    
    @Configuration
    public class AppConfig {
    
    
        @Bean
        public JmsComponent activemq() throws Exception {
            // Create the connectionfactory which will be used to connect to Artemis
            ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory();
            cf.setBrokerURL("tcp://localhost:61616");
            cf.setUser("admin");
            cf.setPassword("admin");
    
            // Create the Camel JMS component and wire it to our Artemis connectionfactory
            JmsComponent jms = new JmsComponent();
            jms.setConnectionFactory(cf);
            return jms;
        }
    
    
    
        @Bean
        public JmsComponent wmq(){
            JmsComponent jmsComponent = new JmsComponent();
            jmsComponent.setConnectionFactory(mqQueueConnectionFactory());
            return jmsComponent;
        }
    
        @Bean
        public MQQueueConnectionFactory mqQueueConnectionFactory() {
        // Create the connectionfactory which will be used to connect to IBM MQ
            MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();
            mqQueueConnectionFactory.setHostName("localhost");
            try {
                mqQueueConnectionFactory.setTransportType(1);
                mqQueueConnectionFactory.setChannel("DEV.APP.SVRCONN");
                mqQueueConnectionFactory.setPort(1414);
                mqQueueConnectionFactory.setQueueManager("QM1");
            } catch (Exception e) {
               e.printStackTrace();
            }
            return mqQueueConnectionFactory;
        }
    
        @Bean
        public UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter(
                MQQueueConnectionFactory mqQueueConnectionFactory) {
            UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter = new UserCredentialsConnectionFactoryAdapter();
            userCredentialsConnectionFactoryAdapter.setUsername("username");
            userCredentialsConnectionFactoryAdapter.setPassword("password");
            userCredentialsConnectionFactoryAdapter.setTargetConnectionFactory(mqQueueConnectionFactory);
            return userCredentialsConnectionFactoryAdapter;
        }
    
    }
    

    The Red Hat AMQ connection factory is now available under the activemq id. The IBM MQ connection factory is available under the wmq id.

    Add the route definition

    We're almost done. Our final step is to add the RouteBuilder class, which contains the route definition:

    package com.sample;
    
    import org.apache.camel.builder.RouteBuilder;
    import org.springframework.stereotype.Component;
    
    @Component
    public class CamelArtemisRouteBuilder extends RouteBuilder {
    
        public void configure() throws Exception {
    
    
            from("timer:mytimer?period=5000").routeId("generate-route")
                    .transform(constant("HELLO from Camel!"))
                    .to("activemq:queue:QueueIN");
    
    
            from("activemq:queue:QueueIN").routeId("receive-route")
                    .log("Received a message - ${body} - sending to outbound queue")
                    .to("wmq:queue:DEV.QUEUE.1?exchangePattern=InOnly");
    
    
        }
    }
    

    In the above route, messages are produced from a timer component that fires new messages every five seconds. Messages are sent through the Red Hat AMQ queue named QueueIN. After logging the message body, they are sent to the sink destination, which is DEV.QUEUE.1.

    We've completed the integration setup. Next, we'll run the application and verify that it's working.

    Start the brokers and run the application

    Before running the application, we need to start the two broker instances. Make sure your Red Hat AMQ server is up and running. If it is not already running, enter the following command:

    ./artemis run
    

    Next, start IBM MQ. For this purpose, you can use a container image of IBM MQ with the developer license:

    $ podman run --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --publish 1414:1414 --publish 9443:9443 --detach ibmcom/mq
    

    Finally, use the standard Spring Boot Maven plug-in to start the Red Hat Fuse application:

    $ mvn spring-boot:run
    

    Verify the application

    As the application starts, you will see from the Spring Boot console that messages are logged on the console:

    12:10:12.552 [Camel (camel-1) thread #1 - JmsConsumer[INCOMING]] INFO receive-route - Received a message - HELLO from Camel! - sending to outbound queue
    13:20:37.935 [Camel (camel-1) thread #1 - JmsConsumer[INCOMING]] INFO receive-route - Received a message - HELLO from Camel! - sending to outbound queue
    13:20:42.954 [Camel (camel-1) thread #1 - JmsConsumer[INCOMING]] INFO receive-route - Received a message - HELLO from Camel! - sending to outbound queue
    13:20:47.966 [Camel (camel-1) thread #1 - JmsConsumer[INCOMING]] INFO receive-route - Received a message - HELLO from Camel! - sending to outbound queue
    

    You can log into the running container process to check that the message has been received on the IBM MQ side:

    $ podman ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    52f0f72d56ed docker.io/ibmcom/mq:latest 5 hours ago Up 5 hours ago 0.0.0.0:1414->1414/tcp pensive_bose

    The output shows the message has been received:

    $ podman exec --tty --interactive 52f0f72d56ed bash bash-4.4$ /opt/mqm/samp/bin/amqsbcg DEV.QUEUE.1 QM1
    
    MQGET of message number 1
    ****Message descriptor****
    
    StrucId : 'MD ' Version : 2
    Report : 0 MsgType : 8
    Expiry : -1 Feedback : 0
    Encoding : 546 CodedCharSetId : 850
    Format : 'MQEVENT '
    Priority : 0 Persistence : 0
    MsgId : X'414D512073617475726E2E71756575650005D30033563DB8'
    CorrelId : X'000000000000000000000000000000000000000000000000'
    BackoutCount : 0
    ReplyToQ : ' '
    ** Identity Context
    UserIdentifier : ' '
    AccountingToken :
    X'0000000000000000000000000000000000000000000000000000000000000000'
    ApplIdentityData : ' '
    ** Origin Context
    PutApplType : '7'
    PutDate : '19970417' PutTime : '15115208'
    ApplOriginData : ' '
    GroupId : X'000000000000000000000000000000000000000000000000'
    MsgSeqNumber : '1'
    Offset : '0'
    MsgFlags : '0'
    OriginalLength : '104'
    
    **** Message ****
    
    length - 104 bytes
    

    Conclusion

    This article discussed how to connect multiple JMS providers (in this case, Red Hat AMQ and IBM MQ) by registering their JMS ConnectionFactory components as Spring beans. After registering the ConnectionFactory beans, we injected them into a Camel JMS component configuration. We then defined the Camel JMS component and used it as part of a Camel route to move messages from both ends of the application.

    To get started with Red Hat Fuse, visit the Red Hat Fuse download page. To learn more about using Red Hat Fuse for message broker integration, see Integrate IBM WebSphere MQ with JBoss Fuse.

    About the author

    Francesco Marchioni is a senior technical account manager for Red Hat Middleware products based in Rome, Italy. Read more about open source contributions to the JBoss developer community at mastertheboss.com.

    Recent Posts

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.