0
我最近为AcitveMQ设置了一些日志记录,作为fire and forget服务,这样应用程序就可以将消息发送到“ActivityLoggingChannel”而不必处理伐木的横切关注。JMS&Spring集成,删除对拥有ActiveMQ实例的依赖
一切都发送到ActivityLoggingGateway,它只是一个默认通道的接口。然后,它向Pojo(dyanmic路由器)查询频道名称以获取消息终点。动态路由器有一个JMX入口点,可以让我在运行中切换终点。如果消息结束点设置为jmsChannelSender,并且无法解析ActiveMQ网址,则会导致整个系统崩溃。
时遇到的问题是,如果所述的ActiveMQ URL不可达我希望系统恢复到其使用不同的消息信道的简单的多线程中处理的方法。
下面是弹簧集成配置。使用版本2.0.0.RELEASE
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx"
xsi:schemaLocation="http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx-2.0.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<import resource="dm-activitylogging-services.xml"/>
<bean name="decisionActivityLoggingAspect" class="com.idna.dm.aspects.logging.activity.DecisionActivityLogAspect"
factory-method="aspectOf">
<property name="activityLoggingGateway">
<ref bean="activityLoggingGateway" />
</property>
</bean>
<!-- New Activity Logging Services Reference dm-activity-logging -->
<!-- JMS Channel Adapter -->
<int:channel id="jmsSenderChannel" />
<bean id="destinationLocalQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg index="0" value="${activemq.queuename.activitylogging}" />
</bean>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
</bean>
<bean id="activityLogConverter" class="com.idna.dm.domain.activitylogging.jms.ActivityLogConverter" />
<jms:outbound-channel-adapter channel="jmsSenderChannel" destination="destinationLocalQueue" connection-factory="connectionFactory" message-converter="activityLogConverter"/>
<!-- In Process Adapter -->
<int:channel id="inProcessChannel" />
<int:outbound-channel-adapter channel="inProcessChannel" ref="inProcessAdapter" method="persistLog" />
<bean id="inProcessAdapter" class="com.idna.dm.logging.activity.impl.InProcessActivityLoggingImpl" >
<property name="activityLoggingService" >
<ref bean="activityLogging" />
</property>
</bean>
<int:channel id="asyncInProcessChannel" />
<int:outbound-channel-adapter channel="asyncInProcessChannel" ref="asyncInProcessAdapter" method="persistLog" />
<bean id="asyncInProcessAdapter" class="com.idna.dm.logging.activity.impl.AsyncInProcessActivityLoggingImpl" >
<property name="activityLoggingService">
<ref bean="activityLogging" />
</property>
</bean>
<!-- Custom channel for console output using the router -->
<!-- Console Channel
<int:channel id="consoleAdapterChannel" />
<int:outbound-channel-adapter channel="consoleAdapterChannel" ref="consoleAdapter" method="printToStdout" />
<bean id="consoleAdapter" class="com.idna.dm.logging.activity.util.StdoutTargetAdapter" />
-->
<!-- Log4j Channel -->
<int:channel id="loggingChannel" />
<int:logging-channel-adapter auto-startup="true" level="INFO" log-full-message="true" channel="loggingChannel" />
<!-- Router -->
<int:gateway id="activityLoggingGateway"
service-interface="com.idna.dm.logging.activity.logger.ActivityLoggingGateway" />
<int:channel id="activityLoggingChannel" />
<int:router input-channel="activityLoggingChannel" ref="dynamicRouter"
method="route" default-output-channel="asyncInProcessChannel"
ignore-channel-name-resolution-failures="true" />
<bean id="dynamicRouter" class="com.idna.dm.logging.activity.router.DynamicRouter">
<constructor-arg index="0" value="asyncInProcessChannel" />
</bean>
好主意,那么问题是什么? – iwein 2011-05-06 11:14:19
对不起在这里,我的问题是不相关了,但我是问找到一种方法来恢复到故障转移的ActiveMQ的一个异步通道作为。因此,如果MQ下去,那么我会通过通使用MQ干脆。我们现在有一个单独的活动MQ实例作为故障转移服务器,因此这不再是问题。 – DeliveryNinja 2011-05-09 14:43:01