ExchangeTimedOutException:未收到OUT消息

时间:2014-12-20 16:13:09

标签: java apache-camel activemq endpoint apache-servicemix

我在使用aciveMq时使用的InOnly交换模式存在问题。

我写了一个在ServiceMix中运行的模块。它正常工作,除了它将每个消息发送到死信队列(ActiveMQ.DLQ)。如果我检查消息,那么dlqDeliveryFailureCause包含以下消息:java.lang.Throwable:Message Expired。

我检查了JMSExpiration = 0.

路线:

    from("direct:" + reqOutQueue).id("reqInEnritch")
    .log("Start dispatch")
    .setExchangePattern(ExchangePattern.InOnly)
    .recipientList().method(EsbDynamicRouter.class, "systemRoute").parallelProcessing();

函数,返回端点列表的内容:

@RecipientList
public String[] systemRoute(@Body Object body) throws Exception
{
    String[] result = null;

    List<DispConfView> targetList;
    int cikl = 0;
    SystemQueueHelper systemInfo;
    MessageHeaderHelper msgHeadHelp = new MessageHeaderHelper(body);

    // The object contains the affected elements
    targetList = dispHelp.getDispConfByMsgType(msgHeadHelp.getMsgType());

    result = new String[targetList.size()];

    for (DispConfView element : targetList)
    {
        // It builds the target andpoints
        systemInfo = new SystemQueueHelper(element.getSystemCode(), null, msgHeadHelp.getDirection());

        result[cikl] = systemInfo.getQueuName();

        cikl++;
    }

    return result;
}

该列表包含以下值:

activemq:queue:ERP.req.in?exchangePattern=InOnly
activemq:queue:WF.req.in?exchangePattern=InOnly

如您所见,我尝试设置正确的模式,但每条消息都会进入死信队列。

请帮忙,我要设置什么!

谢谢!

1 个答案:

答案 0 :(得分:2)

解决方案: 它可以在上下文文件中设置:

<!-- JMS configuration -->  
<bean id="pooledJmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
    <property name="maxConnections" value="1" />
    <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="failover:(tcp://localhost:61616)" />
    <property name="redeliveryPolicy">
        <bean class="org.apache.activemq.RedeliveryPolicy">
            <property name="maximumRedeliveries" value="5"/>
        </bean>
    </property>
</bean>

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="pooledJmsConnectionFactory"/>
    <property name="cacheLevelName" value="CACHE_CONSUMER" />
    <property name="disableReplyTo" value="true" />
</bean>

“jmsConfig bean”“diasbleReplayTo”属性解决了这个问题。