Are there any benefits in using the “failover:” pr

2019-08-26 17:49发布

问题:

According to this answer, there are benefits from using the "failover" protocol with a "tcp" transport, even with a single address.

In addition to this, the ActiveMQ documentation, the following applies (emphasis mine):

If a JMS broker goes down, ActiveMQ can automatically reconnect to an available JMS broker using the failover: protocol. Not only does this automatically reconnect, it will also resume any temporary destinations, sessions, producers and most importantly consumers.

Does this also apply when using the "vm" transport?

We are seeing frequent issues with queue consumers stopping to pick up messages, while the queue fills up, and we have not found a fix for this yet. This is with ActiveMQ v5.6.0 - we're upgrading to v5.14.5 at the moment, but want to explore additional options, too.

Our current Spring configuration for the ActiveMQConnectionFactory looks like this:

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
    depends-on="amqEmbeddedBroker">
    <property name="brokerURL" value="vm://localhost" />
    <property name="watchTopicAdvisories" value="false" />
</bean>

Would changing the URL from vm://localhost to failover:(vm://localhost) provide any benefit in this case, i.e. safe-guarding against connections being closed for whatever reason? When changing the URL to include the failover: part, I can see that an instance of FailoverTransport is created, but does it provide any benefit in the case of the vm transport?

回答1:

Failover will try to get a reconnection if the connection fails. So if you're doing an operation that would normally crash of connection failure, you won't see an exception but it will silently try to reconnect. So if your in memory broker goes dead, the client will be silent and perhaps issue some log that it tries to reconnect.

VM connections do not fail because of network issues, so you may want to investigate further. But upgrading seems like the first step.