设定:
我正在尝试使用ActiveMQ的故障转移协议与Mule和两个Apollo ActiveMQ服务器。如果我关闭其中一个ActiveMQ服务器,Mule将不会像我期望的那样将连接故障转移到第二个MQ服务器。
我在ActiveMQ连接器上使用和不使用重新连接策略尝试过它。
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="properties" />
<jms:activemq-connector name="Active_MQ" username="${mq.user}" password="${mq.password}" brokerURL="failover:(tcp://mq-szt-1:61613,tcp://mq-szt-2:61613)" validateConnections="true" doc:name="Active MQ">
<reconnect/>
</jms:activemq-connector>
<jms:activemq-connector name="Active_MQ_1" username="${mq.user}" password="${mq.password}" brokerURL="tcp://mq-szt-1:61613" validateConnections="true" doc:name="Active MQ 1 "/>
<jms:activemq-connector name="Active_MQ_2" username="${mq.user}" password="${mq.password}" brokerURL="tcp://mq-szt-2:61613" validateConnections="true" doc:name="Active MQ 2"/>
<flow name="activemqtestingFlow1" doc:name="activemqtestingFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" doc:name="HTTP"/>
<jms:outbound-endpoint queue="amq" connector-ref="Active_MQ" doc:name="JMS"/>
<echo-component doc:name="Echo"/>
</flow>
<flow name="activemqtestingFlow2" doc:name="activemqtestingFlow2">
<composite-source doc:name="Composite Source">
<jms:inbound-endpoint queue="amq" connector-ref="Active_MQ_1" doc:name="JMS"/>
<jms:inbound-endpoint queue="amq" connector-ref="Active_MQ_2" doc:name="JMS"/>
</composite-source>
<echo-component doc:name="Echo"/>
</flow>
</mule>
如果两个MQ服务器都已启动,则通过工作发送消息...
INFO 2014-03-20 08:51:20,833 [main] org.mule.module.launcher.MuleDeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'activemqtesting' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2014-03-20 08:52:14,877 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
INFO 2014-03-20 08:52:14,878 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
WARN 2014-03-20 08:52:14,878 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.transport.jms.JmsMessageDispatcher: Starting patched JmsMessageReceiver
INFO 2014-03-20 08:52:14,878 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'Active_MQ.dispatcher.362048839'. Object is: JmsMessageDispatcher
INFO 2014-03-20 08:52:14,879 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'Active_MQ.dispatcher.362048839'. Object is: JmsMessageDispatcher
INFO 2014-03-20 08:52:15,109 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: activemqtestingFlow1. Content is: '/test1' *
********************************************************************************
INFO 2014-03-20 08:52:15,198 [[activemqtesting].activemqtestingFlow2.stage1.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: activemqtestingFlow2. Content is: '/test1' *
********************************************************************************
INFO 2014-03-20 08:52:15,737 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: activemqtestingFlow1. Content is: *
* '/favicon.ico' *
********************************************************************************
INFO 2014-03-20 08:52:15,744 [[activemqtesting].activemqtestingFlow2.stage1.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: activemqtestingFlow2. Content is: *
* '/favicon.ico' *
********************************************************************************
在mq-szt-2上,我看到en-queue和de-queue计数器已经递增,所以我在mq-szt-2上停止了ActiveMQ服务。我希望Mule能够故障转移到mq-szt-1,但传输失败了。当我尝试发送其他消息时,我收到了“无法传输”错误。下面的骡子错误......
WARN 2014-03-20 08:52:33,287 [ActiveMQ Transport: tcp://mq-szt-2./10.0.0.43:61613@21348] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.43:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
ERROR 2014-03-20 08:52:33,291 [ActiveMQ Connection Executor: tcp://mq-szt-2./10.0.0.43:61613@21350] org.mule.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message : Connection reset (javax.jms.JMSException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Connection reset (java.net.SocketException)
java.net.SocketInputStream:-1 (null)
2. Connection reset(JMS Code: null) (javax.jms.JMSException)
org.apache.activemq.util.JMSExceptionSupport:54 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
3. Connection reset (javax.jms.JMSException) (org.mule.transport.ConnectException)
org.mule.transport.jms.JmsConnector:508 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.activemq.transport.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2014-03-20 08:52:33,291 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.exception.DefaultSystemExceptionStrategy: Exception caught is a ConnectException, attempting to reconnect...
INFO 2014-03-20 08:52:33,292 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.lifecycle.AbstractLifecycleManager: Stopping connector: Active_MQ_2
INFO 2014-03-20 08:52:33,293 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.lifecycle.AbstractLifecycleManager: Stopping: 'null'. Object is: MultiConsumerJmsMessageReceiver
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms message consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms session consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms message consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms session consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms message consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms session consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms message consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,294 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Failed to close jms session consumer: Cannot send, channel has already failed: tcp://10.0.0.43:61613
WARN 2014-03-20 08:52:33,297 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Exception cleaning up JMS connection: null
WARN 2014-03-20 08:52:33,298 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Exception closing JMS connection: Connection reset
INFO 2014-03-20 08:52:33,298 [ActiveMQ Connection Executor: tcp://mq-szt-2/10.0.0.43:61613@21350] org.mule.transport.jms.activemq.ActiveMQJmsConnector: Disconnected: ActiveMQJmsConnector
{
name=Active_MQ_2
lifecycle=stop
this=540f51ab
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[jms]
serviceOverrides=<none>
}
ERROR 2014-03-20 08:52:33,320 [ActiveMQ Connection Executor: tcp://mq-szt-1:61613] org.mule.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message : org.apache.activemq.apollo.openwire.OpenwireProtocolHandler$ProtocolException: Unspported command: class org.apache.activemq.apollo.openwire.command.ConnectionControl (javax.jms.JMSException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. org.apache.activemq.apollo.openwire.OpenwireProtocolHandler$ProtocolException: Unspported command: class org.apache.activemq.apollo.openwire.command.ConnectionControl (java.lang.Throwable)
org.apache.activemq.apollo.openwire.OpenwireProtocolHandler:346 (null)
2. org.apache.activemq.apollo.openwire.OpenwireProtocolHandler$ProtocolException: Unspported command: class org.apache.activemq.apollo.openwire.command.ConnectionControl(JMS Code: null) (javax.jms.JMSException)
org.apache.activemq.util.JMSExceptionSupport:54 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
3. org.apache.activemq.apollo.openwire.OpenwireProtocolHandler$ProtocolException: Unspported command: class org.apache.activemq.apollo.openwire.command.ConnectionControl (javax.jms.JMSException) (org.mule.transport.ConnectException)
org.mule.transport.jms.JmsConnector:508 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.Throwable: org.apache.activemq.apollo.openwire.OpenwireProtocolHandler$ProtocolException: Unspported command: class org.apache.activemq.apollo.openwire.command.ConnectionControl
at org.apache.activemq.apollo.openwire.OpenwireProtocolHandler.fail(OpenwireProtocolHandler.scala:346)
at org.apache.activemq.apollo.openwire.OpenwireProtocolHandler.fail(OpenwireProtocolHandler.scala:343)
at org.apache.activemq.apollo.openwire.OpenwireProtocolHandler.die(OpenwireProtocolHandler.scala:397)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2014-03-20 08:52:33,320 [ActiveMQ Connection Executor: tcp://mq-szt-1:61613] org.mule.exception.DefaultSystemExceptionStrategy: Exception caught is a ConnectException, attempting to reconnect...
INFO 2014-03-20 08:52:33,320 [ActiveMQ Connection Executor: tcp://mq-szt-1:61613] org.mule.lifecycle.AbstractLifecycleManager: Stopping connector: Active_MQ
INFO 2014-03-20 08:52:33,322 [ActiveMQ Connection Executor: tcp://mq-szt-1:61613] org.mule.lifecycle.AbstractLifecycleManager: Stopping: 'Active_MQ.dispatcher.362048839'. Object is: JmsMessageDispatcher
INFO 2014-03-20 08:52:33,322 [ActiveMQ Connection Executor: tcp://mq-szt-1:61613] org.mule.lifecycle.AbstractLifecycleManager: Disposing: 'Active_MQ.dispatcher.362048839'. Object is: JmsMessageDispatcher
WARN 2014-03-20 08:52:38,335 [ActiveMQ Transport: tcp://mq-szt-1/10.0.0.33:61613@21370] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.33:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
ERROR 2014-03-20 08:52:45,375 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Cannot process event as "Active_MQ" is stopped
Code : MULE_ERROR-166
--------------------------------------------------------------------------------
Exception stack is:
1. Cannot process event as "Active_MQ" is stopped (org.mule.api.lifecycle.LifecycleException)
org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor:42 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/LifecycleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.lifecycle.LifecycleException: Cannot process event as "Active_MQ" is stopped
at org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor.handleUnaccepted(ProcessIfStartedMessageProcessor.java:42)
at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-03-20 08:52:45,568 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Cannot process event as "Active_MQ" is stopped
Code : MULE_ERROR-166
--------------------------------------------------------------------------------
Exception stack is:
1. Cannot process event as "Active_MQ" is stopped (org.mule.api.lifecycle.LifecycleException)
org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor:42 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/LifecycleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.lifecycle.LifecycleException: Cannot process event as "Active_MQ" is stopped
at org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor.handleUnaccepted(ProcessIfStartedMessageProcessor.java:42)
at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-03-20 08:52:54,303 [ActiveMQ Connection Executor: tcp://mq-szt-2./10.0.0.43:61613@21350] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: ActiveMQJmsConnector
{
name=Active_MQ_2
lifecycle=stop
this=540f51ab
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=false
supportedProtocols=[jms]
serviceOverrides=<none>
}
. Root Exception was: Connection timed out: connect. Type: class java.net.ConnectException
ERROR 2014-03-20 08:52:54,303 [ActiveMQ Connection Executor: tcp://mq-szt-2./10.0.0.43:61613@21350] org.mule.exception.DefaultSystemExceptionStrategy: Could not connect to broker URL: tcp://mq-szt-2.:61613. Reason: java.net.ConnectException: Connection timed out: connect
ERROR 2014-03-20 08:52:59,206 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
当我尝试发送更多消息时,我收到此错误:
********************************************************************************
Message : Cannot process event as "Active_MQ" is stopped
Code : MULE_ERROR-166
--------------------------------------------------------------------------------
Exception stack is:
1. Cannot process event as "Active_MQ" is stopped (org.mule.api.lifecycle.LifecycleException)
org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor:42 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/LifecycleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.lifecycle.LifecycleException: Cannot process event as "Active_MQ" is stopped
at org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor.handleUnaccepted(ProcessIfStartedMessageProcessor.java:42)
at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-03-20 08:52:59,373 [[activemqtesting].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Cannot process event as "Active_MQ" is stopped
Code : MULE_ERROR-166
--------------------------------------------------------------------------------
Exception stack is:
1. Cannot process event as "Active_MQ" is stopped (org.mule.api.lifecycle.LifecycleException)
org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor:42 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/LifecycleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.lifecycle.LifecycleException: Cannot process event as "Active_MQ" is stopped
at org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor.handleUnaccepted(ProcessIfStartedMessageProcessor.java:42)
at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
WARN 2014-03-20 08:53:04,370 [ActiveMQ Transport: tcp://mq-szt-1/10.0.0.33:61613@21389] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.33:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
如果我再次启动mq-szt-2,我会得到它,它不会重新连接,但我会在日志中看到这个:
WARN 2014-03-20 09:00:26,934 [ActiveMQ Transport: tcp://mq-szt-1/10.0.0.33:61613@21669] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.33:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
WARN 2014-03-20 09:00:52,954 [ActiveMQ Transport: tcp://mq-szt-1/10.0.0.33:61613@21677] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.33:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
WARN 2014-03-20 09:00:58,279 [ActiveMQ Transport: tcp://mq-szt-2/10.0.0.43:61613@21678] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.43:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
WARN 2014-03-20 09:01:03,313 [ActiveMQ Transport: tcp://mq-szt-1/10.0.0.33:61613@21679] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.33:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
WARN 2014-03-20 09:01:08,340 [ActiveMQ Transport: tcp://mq-szt-2/10.0.0.43:61613@21680] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.43:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
WARN 2014-03-20 09:01:13,358 [ActiveMQ Transport: tcp://mq-szt-1/10.0.0.33:61613@21683] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.33:61613) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect
WARN 2014-03-20 09:01:18,387 [ActiveMQ Transport: tcp://mq-szt-2/10.0.0.43:61613@21694] org.apache.activemq.transport.failover.FailoverTransport: Transport (tcp://10.0.0.43:61613) failed, reason:
答案 0 :(得分:1)
没关系。我将MQ服务器从Apollo ActiveMQ切换到ActiveMQ,它按预期工作。我相信这是因为Apollo没有实现ConnectionControl命令。 https://issues.apache.org/jira/browse/APLO-270