ribbonmq超时配置_Spring JMS + IBM MQ:如何设置消息缓冲区大小或等待超时?

I'm unable to process large messages from IBM MQ and get the below error:

JMSCMQ0001: WebSphere MQ call failed with compcode '1' ('MQCC_WARNING') reason '2080' ('MQRC_TRUNCATED_MSG_FAILED')

I'm using the DefaultListenerContainer and not consuming via a MessageConsumer using IBM MQ Java API classes directly. I believe by using IBM MQ JMS API you can specific options before retrieving the message from the queue. But how do I do that with DefaultListenerContainer, is there a system property I can set for these?

If using IBM MQ JMS API(I'm not consuming message like this, pasted just for reference):

MQGetMessageOptions mqGetMessageOptions = new MQGetMessageOptions();

mqGetMessageOptions.waitInterval = ipreoProperties.getMqReceiveWaitTime();

mqGetMessageOptions.options = MQC.MQGMO_WAIT | MQC.MQPMO_SYNCPOINT | MQC.MQGMO_ACCEPT_TRUNCATED_MSG;

Below is my Java Config for the IBM MQ Connection:

@Bean

public CachingConnectionFactory ipreoMQCachingConnectionFactory() {

CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();

//Not defining MQQueueConnectionFactory as separate bean as Spring boot's auto-configuration finds two instances

//of ConnectionFactory and throws ambiguous implementation exception

//One implementation is CachingConnectionFactory and other one would be MQQueueConnectionFactory if defined separately

MQQueueConnectionFactory mqConnectionFactory = new MQQueueConnectionFactory();

try {

mqConnectionFactory.setHostName(env.getRequiredProperty(AppEnvPropertyConstants.JmsConstants.IPREO_MQ_HOSTNAME));

mqConnectionFactory.setQueueManager(env.getRequiredProperty(AppEnvPropertyConstants.JmsConstants.IPREO_MQ_QUEUE_MGR));

mqConnectionFactory.setPort(env.getRequiredProperty(AppEnvPropertyConstants.JmsConstants.IPREO_MQ_PORT, Integer.class));

mqConnectionFactory.setChannel(env.getRequiredProperty(AppEnvPropertyConstants.JmsConstants.IPREO_MQ_CHANNEL));

//mqConnectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);

//Setting connection mode as Client so it doesn't complain for native IBM MQ libraries

mqConnectionFactory.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);

} catch (JMSException exception) {

exception.printStackTrace();

}

cachingConnectionFactory.setTargetConnectionFactory(mqConnectionFactory);

//Setting session caching size as 10, don't think we need more

cachingConnectionFactory.setSessionCacheSize(10);

cachingConnectionFactory.setReconnectOnException(true);

return cachingConnectionFactory;

}

public DefaultMessageListenerContainer ipreoDealActivityListenerContainer() {

DefaultMessageListenerContainer factory = new DefaultMessageListenerContainer();

factory.setConnectionFactory(ipreoMQCachingConnectionFactory());

factory.setDestinationName(env.getRequiredProperty(AppEnvPropertyConstants.JmsConstants.IPREO_DEAL_QUEUE_NAME));

factory.setMessageListener(ipreoDealActivityListener());

factory.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);

return factory;

}

@Bean

public MessageListener ipreoDealActivityListener() {

return new IpreoDealActivityListener();

}

Appreciate your help, thanks.

解决方案

Within the JMS client code handling of the receive buffer us handled automatically; the theory is that specific error should never be received by a JMS Application.

The first snippet of code is the Java Classes API and this could get that error.

How big actually are these messages? What level of the JMS client code are you using - make sure that it is the latest version. And certainly one of the 7.5 or 8 releases.

This answer also has some more information on this.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值