我可以非常简单地设置从HornetQ队列中读取MULE并将Object保存到数据库:
设置如下:
<jms:connector name="connector.jms" maxRedelivery="1" connectionFactory-ref="hornetQConnectionFactory" doc:name="JMS"
createMultipleTransactedReceivers="true"
numberOfConcurrentTransactedReceivers="100"
acknowledgementMode="AUTO_ACKNOWLEDGE">
<reconnect count="50" frequency="5000"/>
</jms:connector>
<flow name="jmsListenerFlow1" doc:name="jmsListenerFlow1">
<jms:inbound-endpoint queue="adsLogQueue" connector-ref="connector.jms" doc:name="JMS">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
<component >
<spring-object bean="logSaver"/>
</component>
</flow>
为什么在maxRedelivery设置为1时,我会在端点上收到消息已重新传递9次的消息?它究竟意味着什么?
hornetQConnectionFactory:
<bean name="hornetQTransportConfiguration" class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"/>
<constructor-arg>
<map>
<entry key="host" value="${jms.host}" />
<entry key="port" value="${jms.port}" />
</map>
</constructor-arg>
</bean>
<bean name="hornetQConnectionFactory" class="org.hornetq.jms.client.HornetQJMSConnectionFactory">
<constructor-arg index="0" value="false"/>
<constructor-arg index="1" ref="hornetQTransportConfiguration"/>
<property name="minLargeMessageSize" value="250000"/>
<property name="cacheLargeMessagesClient" value="false"/>
</bean>
任何帮助将不胜感激!
下面的堆栈跟踪。
ERROR 2012-10-19 01:04:07,283 [Thread-3013 (HornetQ-client-global-threads-1442093417)]: Message : "Message with id "ID:e6a0b303-1977-11e2-96d4-810571a3fe10" has been redelivered 9 times on endpoint "jms://adsLogQueue", which exceeds the maxRedelivery setting of 1 on the connector "connector.jms". Message payload is of type: HornetQObjectMessage Code : MULE_ERROR--2 Exception stack is: 1. "Message with id "ID:e6a0b303-1977-11e2-96d4-810571a3fe10" has been redelivered 9 times on endpoint "jms://adsLogQueue", which exceeds the maxRedelivery setting of 1 on the connector "connector.jms". Message payload is of type: HornetQObjectMessage (org.mule.transport.jms.redelivery.MessageRedeliveredException) org.mule.transport.jms.redelivery.JmsXRedeliveryHandler:91 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/jms/redelivery/MessageRedeliveredException.html) Root Exception stack trace: org.mule.transport.jms.redelivery.MessageRedeliveredException: "Message with id "ID:e6a0b303-1977-11e2-96d4-810571a3fe10" has been redelivered 9 times on endpoint "jms://adsLogQueue", which exceeds the maxRedelivery setting of 1 on the connector "connector.jms". Message payload is of type: HornetQObjectMessage at org.mule.transport.jms.redelivery.JmsXRedeliveryHandler.handleRedelivery(JmsXRedeliveryHandler.java:91) at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$JmsWorker.preProcessMessage(MultiConsumerJmsMessageReceiver.java:418) at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:120) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) ********************************************************************************
答案 0 :(得分:6)
首先要注意的是Mule正在使用JmsXRedeliveryHandler
,这意味着它已经检测到HornetQ支持JMS_X_DELIVERY_COUNT
标题,并将负责计算重新发送的数量。在这种情况下,Mule完全依赖HornetQ提供准确的重新交付数量。
抛出此异常意味着已向Mule呈现JMS消息,其重新传递计数超过JMS连接器上配置的计数(在您的情况下为1)。
由于您在事务中使用,可能会发生的情况是HornetQ将在每次重启时回滚并向Mule表示此消息,一次又一次,除非您已经在HornetQ本身上配置了最大重新传递计数。
我的建议是:在Mule和HornetQ上设置相同的重新传递计数,或在Mule上使用-1(无限制)并完全依赖HornetQ的重新传递限制。