Reputation: 307
I am trying to configure a stable connection which doesn't timeout with the embedded ActiveMQ broker. I am using Camel+ActiveMQ+Spring to configure on the server side. In my broker config I have the below config, I have tried setting connectionTimeOut , wireFormat.maxInactivityDuration=0 on the transport connectors but didn't work, I am using StompClient to connect ws://localhost:61614/stomp?useInactivityMonitor=false
on the client side. The connection gets established but it times out after 300000ms which seems to be the default idle time but can't turn it off, please help at which level this should be configured to ensure the connections don't get dropped :
<broker id="broker" brokerName="myBroker" useShutdownHook="false" useJmx="true" dataDirectory="activemq-data"
xmlns="http://activemq.apache.org/schema/core">
<transportConnectors>
<!-- vm transport for intra-jvm communication-->
<transportConnector name="vm" uri="vm://myBroker?transport.useInactivityMonitor=false"/>
<!-- tcp for external communication -->
<transportConnector name="tcp" uri="tcp://localhost:61616?transport.useInactivityMonitor=false"/>
<transportConnector name="ws" uri="ws://localhost:61614??transport.useInactivityMonitor=false"/>
<transportConnector name="stomp" uri="stomp://localhost:61613?transport.useInactivityMonitor=false"/>
</transportConnectors>
</broker>
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://myBroker?create=false&waitForStart=5000" />
</bean>
<bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="12" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="idleTimeout" value="120000" />
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="concurrentConsumers" value="12"/>
<property name="idleConsumerLimit" value="120000"/>
</bean>
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
Getting this in the log while disconnecting :
WebSocketConnectionRFC6455 DEBUG ClosedOut WebSocketServletConnectionRFC6455 p=WebSocketParserRFC6455@3565d22 state=OPCODE buffer=null g=WebSocketGeneratorRFC6455@309b59a6 closed=false buffer=-1 1000 Idle for 300074ms > 300000ms
Upvotes: 1
Views: 2609
Reputation: 307
It turned out to be the Jetty under the ActiveMQ causing this issue. It has a default idle time out of 300000ms, setting the transport connector as below increased the time out to the set value, setting it to '0' doesn't disable the inactivity monitor as it's suggested for "wireFormat.maxInactivityDuration=0", and using the "wireFormat.maxInactivityDuration=0" alone doesn't work either :
<transportConnectors>
<!-- vm transport for intra-jvm communication-->
<transportConnector name="vm" uri="vm://myBroker"/>
<transportConnector name="ws" uri="ws://localhost:61614?websocket.maxIdleTime=7200000"/>
</transportConnectors>
on the client side, I have the matching URL just in case : "ws://localhost:61614?maxIdleTime=7200000". Couldn't find this in the regular ActiveMQ documentation or anywhere else. It would be nice to see the docs updated for this scenario.
Upvotes: 1