我使用使用spring配置的IBM MQ jars配置来工作JMS应用程序。
它可以很好地处理正确的队列信息,但是当我提供错误的队列信息时。
它挂在
LOG.info("SENDING MESSAGE");
jmsTemplate.send(this.getDestination(), messageCreator ); //here我有我的日志在发送信息,我正在处理org.springframework.jmsexception,但它不会抛出……我认为它就挂在那个点上。
我找不到用于发送超时的jmstemplate的任何属性,只有在接收超时时才有.
下面是应用程序-context.xml (Spring)中的jm茎Spring conf
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">
<property name="connectionFactory">
<ref bean="jmsQueueConnectionFactory" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name="receiveTimeout">
<value>20000</value>
</property>和ibm mq conf -
<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName">
<value>${queue_hostname}</value>
</property>
<property name="port">
<value>${queue_port}</value>
</property>
<property name="queueManager">
<value>${queue_manager}</value>
</property>
<property name="channel">
<value>${queue_channel}</value>
</property>
<property name="transportType">
<value>1</value>
</property>
</bean>我已经把它设置为自动确认
this.jmsTemplate.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);所以,请告诉我如何在发送消息时暂停抛出jmsexception.
发布于 2013-08-08 21:12:37
这都是毫无意义的。
如果试图将消息放入无效队列,MQ将立即抛出一个异常,其原因是代码2085 (未知对象)。不需要超时。显然,您正在使用的框架中有一个错误,即它没有捕获抛出的异常!
只使用JMS和MQ进行相同的测试,您将看到不同之处。
发布于 2013-08-20 17:49:48
@anshulkatta为什么不先验证目标,然后使用JmsDestinationAccessor的方法来设置它。使用resolveDestinationName方法进行验证。因此,您的应用程序将验证目标,否则它将抛出一个JMSException,您可以捕获并记录适当的验证消息。检查http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/jms/support/destination/JmsDestinationAccessor.html
发布于 2017-06-14 11:47:07
查一下Hystrix图书馆。在它的帮助下,您可以管理连接的超时。将超时设置为HystrixCommandProperties.Setter并将其传递给HystrixCommand类。
HystrixCommandProperties.Setter commandPropertiesDefaults = HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(timeout);然后从HystrixCommand类中运行execute()方法。
https://stackoverflow.com/questions/18128102
复制相似问题