java监听ibmq消息_SpringBoot 对IBM MQ进行数据监听接收以及数据发送

本文介绍了如何在Spring Boot应用中利用IBM MQ进行数据监听接收和回执发送。首先,文章列举了所需的依赖,然后详细阐述了MQ通道连接、监听实现和消息发送的步骤,包括创建MQQueueConnectionFactory、SimpleMessageListenerContainer、以及实现MessageListener接口来处理接收到的消息。最后,展示了MQ配置文件和报文处理类的代码细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、需求介绍

后端使用spring boot2.0框架,要实现ibm mq的实时数据jms监听接收处理,并形成回执通过mq队列发送。

二、引入依赖jar包

org.springframework

spring-jms

4.3.18.release

javax.jms

javax.jms-api

com.ibm.mq

com.ibm.mq.allclient

9.1.0.0

三、监听实现

代码中分为三大块:

1、mq通道连接,我这边是用的用户名密码连接,如果非密码的可不入参

2、mq的队列连接并实现监听

3、mq发送

@configuration

public class mqtestconfig {

@autowired

private mqproperties mqproperties;

/**=======================mq 通道工厂============================**/

@bean(name="mqqueueconnectionfactory")

public mqqueueconnectionfactory mqqueueconnectionfactory(){

mqqueueconnectionfactory mqqueueconnectionfactory = new mqqueueconnectionfactory();

mqqueueconnectionfactory.sethostname(mqproperties.gethostname());

try {

mqqueueconnectionfactory.settransporttype(wmqconstants.wmq_cm_client);

mqqueueconnectionfactory.setccsid(mqproperties.getccsid());

mqqueueconnectionfactory.setchannel(mqproperties.getchannel());

mqqueueconnectionfactory.setport(mqproperties.getport());

mqqueueconnectionfactory.setqueuemanager(mqproperties.getqueuemanager());

} catch (jmsexception e) {

e.printstacktrace();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值