How can we connect ActiveMQ and WebSphere MQ in one Spring Boot application?

79 views Asked by At

In Spring Boot 2.6.11 application we are trying to consume data from ActiveMQ and publish data to WebSphere MQ.

For that if we need to manual configure both the ActiveMQ and WebSphere MQ? If yes then how? I am using below ActiveMQ config:

@Bean
public Queue producerQueue() {
    return new ActiveMQQueue(PRODUCER_QUEUE);
}

@Bean
public Queue consumerQueue() {
    return new ActiveMQQueue(CONSUMER_QUEUE);
}

@Bean
public ActiveMQConnectionFactory activeMQConnectionFactory() {
    ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
    activeMQConnectionFactory.setBrokerURL(BROKER_URL);
    activeMQConnectionFactory.setPassword(BROKER_PASSWORD);
    activeMQConnectionFactory.setUserName(BROKER_USERNAME);
    activeMQConnectionFactory.setTrustAllPackages(true);
    return activeMQConnectionFactory;
}

@Bean
public JmsTemplate jmsTemplate() {
    return new JmsTemplate(activeMQConnectionFactory());
} 

How can I configure WebSphere MQ in the same application? I have added below dependency for WebSphere MQ:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.11.4</version>
</dependency>      
<dependency>
   <groupId>com.ibm.mq</groupId>
   <artifactId>mq-jms-spring-boot-starter</artifactId>
   <version>2.0.0</version>
</dependency>

wmq properties

ibm.mq.queueManager=XXX
ibm.mq.channel=XXX
ibm.mq.connName=XXX
ibm.mq.connPort=XXX
ibm.mq.queueName=XXX
ibm.mq.user=XXX
ibm.mq.password=XXX

I am getting one bean of JmsTemplate which is connecting to ActiveMQ only. How can I create JmsTemplate bean for WebSphere MQ to publish the data?

0

There are 0 answers