我正在使用Mule 3.5.0 CE版。 我有2个要求:
要使用Mule进行管理,我正在考虑使用ActiveMQ BlobMessage来管理有效负载和可靠的采集模式。 首先,我想知道这是否是最佳方法?
这是我创造的:
然而,在AMQ崩溃的情况下,我正在丢失消息......
我在mule中有一些警告“无法尝试从处理中的文件列表中删除文件'...'并出现以下错误:
ERROR 2015-05-23 12:55:38,291 [[opx].File.receiver.01] org.mule.exception.DefaultMessagingExceptionStrategy: ******************************************************************************** Message : Cannot process event as "Active_MQ" is stopped Type : org.mule.api.lifecycle.LifecycleException Code : MULE_ERROR-70167 JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/LifecycleException.html ******************************************************************************** Exception stack is: 1. Cannot process event as "Active_MQ" is stopped (org.mule.api.lifecycle.LifecycleException) org.mule.lifecycle.processor.ProcessIfStartedMessageProcessor:38 (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:38) at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:44) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.endpoint.DefaultOutboundEndpoint.process(DefaultOutboundEndpoint.java:100) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:54) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:40) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.construct.AbstractPipeline$1.process(AbstractPipeline.java:109) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.construct.AbstractPipeline$3.process(AbstractPipeline.java:207) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58) at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) at org.mule... ********************************************************************************
编辑:这是配置。
流程:
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616?jms.redeliveryPolicy.initialRedeliveryDelay=3000&jms.blobTransferPolicy.defaultUploadUrl=http://localhost:8161/fileserver/" validateConnections="true" maxRedelivery="-1" cacheJmsSessions="false" persistentDelivery="true" doc:name="Active MQ" >
<reconnect frequency="60000" count="20"/>
</jms:activemq-connector>
<file:connector name="File" workDirectory="/home/fs/workDirectory" autoDelete="true" streaming="true" validateConnections="true"/>
<flow name="ReceiveFromFS" processingStrategy="synchronous">
<file:inbound-endpoint path="/home/fs/in" pollingFrequency="5000" fileAge="1000" connector-ref="File"/>
<component class="mypackage.InputStreamToBlobMessage" doc:name="Java"/>
<jms:outbound-endpoint queue="queue1" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
我的java组件:
public class InputStreamToBlobMessage实现Callable {
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
MuleMessage muleMsg = eventContext.getMessage();
InputStream is = (InputStream) muleMsg.getPayload();
JmsConnector amqConnector = (JmsConnector) eventContext.getMuleContext().getRegistry().lookupConnector("Active_MQ");
BlobMessage bm = null;
if (amqConnector.isConnected())
{
ActiveMQSession session = (ActiveMQSession) amqConnector.getSession(false, false);
bm = session.createBlobMessage(is);
}
return bm;
}
}
答案 0 :(得分:0)
在这种情况下,您的重新连接尝试已经耗尽,这就是您的连接器停留在“停止”状态的原因。状态。
请尝试用
替换您的重新连接策略<reconnect-forever frequency="60000" />
答案 1 :(得分:0)
这里我使用的配置有效:
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" connectionFactory-ref="connectionFactory" validateConnections="true" maxRedelivery="-1" persistentDelivery="true" doc:name="Active MQ">
</jms:activemq-connector>
<spring:beans>
<spring:bean name="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" doc:name="Bean">
<spring:property name="redeliveryPolicy">
<spring:bean name="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<spring:property name="redeliveryDelay" value="60000"/>
<spring:property name="maximumRedeliveries" value="20"/>
<spring:property name="initialRedeliveryDelay" value="10000"/>
</spring:bean>
</spring:property>
<spring:property name="blobTransferPolicy">
<spring:bean name="blobTransferPolicy" class="org.apache.activemq.blob.BlobTransferPolicy">
<spring:property name="defaultUploadUrl" value="http://localhost:8161/fileserver/"/>
</spring:bean>
</spring:property>
</spring:bean>
</spring:beans>
<file:connector name="File" workDirectory="/home/fs/workDirectory" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="ReceiveFromFS" processingStrategy="synchronous">
<file:inbound-endpoint path="/home/fs/in" pollingFrequency="5000" fileAge="1000" connector-ref="File"/>
<component class="mypackage.InputStreamToBlobMessage" doc:name="Java"/>
<jms:outbound-endpoint queue="queue1" connector-ref="Active_MQ" doc:name="JMS">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:outbound-endpoint>
</flow>
然而,当我在MuleStudio中使用connectionFactory时,它无法正常工作并且管理了重试。错误? 在Tomcat中嵌入的Mule中使用相同的配置工作正常。
还有一件事,在Mule 3.6中,默认情况下会缓存JMS会话,因此可以按照我在组件中的方式访问Session,或者必须使用cacheJmsSessions =“false”。
Voilà:)