问题
We have swing GUI clients that are connecting to a server process.
The clients 'call' services on the server using jms:queue
'from' endpoints defined in Camel routes, and using ActiveMQ as the underlying JMS broker.
However, the client also offers a Camel jms:topic
endpoint for the server to broadcast messages back to the client.
Unfortunately, it looks like the topic connection is getting lost somehow, and although the client can still 'call' the services on the server, the server cannot send any messages to the client's topic endpoint.
The client-side spring definition of the Camel endpoint is as follows:
<camel:route>
<camel:from uri="jms:topic:inUseQueue"/>
<camel:to uri="bean:inUseInterfaceImpl"/>
</camel:route>
And the server-side producer is defined as follows:
<bean id="inUseManagerImpl" class="org.apache.camel.spring.remoting.CamelProxyFactoryBean">
<property name="serviceUrl" value="jms:topic:inUseQueue"/>
<property name="serviceInterface" value="uniworks.core.inuse.InUseInterface"/>
</bean>
Does anyone know of a way that we can somehow detect the loss of this topic connection on the client side?
回答1:
An easy workaround shall be to override isSingleton()
method of CamelProxyFactoryBean
. Return false and let spring create the producer bean on every invocation instead of caching it. Or you can also define the scope of CamelProxyFactoryBean
to be prototype.
Also you can try with the ActiveMQ camel component that supports connection pooling.
回答2:
I realize this is a 8 month old question, but hey what the hell.
would it make sense to make the server broadcast "isalive" message once a minute, this way if the client doesn't get any of the "isalive" messages it can presume it has been disconnected.
来源:https://stackoverflow.com/questions/20601287/how-to-detect-loss-of-jms-topic-connection