Enable socket timeout on ActiveMQ from Camel route?

So, I have Camel (via Spring DSL) successfully integrating my beans with ActiveMQ queues:

<!-- Note: this code is just a snippet; if you need to see more, please let me know! -->
<camelContext id="my-camel-context" xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="activemq-myinstance:queue:myqueue" />
        <onException>
            <exception>java.lang.Exception</exception>
            <redeliveryPolicy maximumRedeliveries="2" />
            <to uri="activemq-myinstance:queue_failures" />
        </onException>
        <to uri="bean:myBean?method=doCommand" />           
    </route>
</camelContext>

<bean id="jmsConnectionFactory-myqueue" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${activemq.instance.url}" />
</bean>

<bean id="pooledConnectionFactory-myqueue" class="org.apache.activemq.pool.PooledConnectionFactory">
    <property name="maxConnections" value="64" />
    <property name="maximumActive" value="${max.active.consumers}" />
    <property name="connectionFactory" ref="jmsConnectionFactory-myqueue" />
</bean>

<bean id="jmsConfig-myqueue" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="pooledConnectionFactory-myqueue"/>
    <property name="concurrentConsumers" value="${max.active.consumers}"/>
</bean>

<bean id="activemq-myqueue" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="jmsConfig-myqueue"/> 
</bean>

I want the socket to timeout explicitly (on Socket.read()) - between Camel and ActiveMQ - 25 seconds. Thus, when Camel tries to forward a message to / from ActiveMQ, if ActiveMQ takes more than 25 seconds to complete this response, I want the stream to be graceful. Obviously, if it is also possible to configure some kind of transition to another resource (so that requests that time out may be received again in the future), which are very preferable, simply losing the message!

How can i do this? Thanks in advance!

: Camel/JMS/ActiveMQ , "ThreadManager", / 25 , , / / Spring beans.

+5
2

Camel activemq 20 .

- sendTimeout org.apache.activemq.ActiveMQConnectionFactory. requesttimeout JMSConfiguraiton.

URL- .

+1

timeout brokerURL

failover:(tcp\://localhost\:61616)?timeout=25000

, , ...

+1

All Articles