2011-01-19 5 views
0

최근에 어플리케이션이 "ActivityLoggingChannel"에 메시지를 보내고 처리 할 필요가 없도록 Fire and forget 서비스로 AcitveMQ에 대한 일부 로깅을 설정했습니다 로깅의 교차 절단 문제.ActiveMQ 인스턴스에 대한 종속성을 제거한 JMS 및 Spring 통합

모든 것이 기본 채널이있는 인터페이스 인 ActivityLoggingGateway로 전송됩니다. 그러면 Pojo (다이나 믹 라우터)에 채널 이름을 쿼리하여 메시지 끝점을 가져옵니다. 동적 라우터에 대한 JMX 진입 점이있어 즉시 엔드 포인트를 전환 할 수 있습니다. 메시지 끝점이 jmsChannelSender로 설정되어 있고 ActiveMQ URL을 확인할 수없는 경우 전체 시스템이 넘어집니다.

난 데 문제는 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> 
+0

좋은 아이디어가 무엇입니까? – iwein

+0

죄송합니다 여기 내 질문은 더 이상 관련이 없지만 ActiveMQ에 대한 장애 조치로 비동기 채널로 되돌릴 방법을 찾는 방법에 대해 묻고있었습니다. 그러므로 MQ가 다운 되었다면 MQ를 사용하여 패스 할 것입니다. 이제 장애 조치 서버로 별도의 활성 MQ 인스턴스가 생겨 더 이상 문제가되지 않습니다. – DeliveryNinja

답변

0

를 사용하면 당신은 failover 메커니즘을 사용하여 달성 할 수있다 :이 경우 첫 번째 <service-activator>에서

<channel id="input"> 
    <dispatcher load-balancer="none"/> 
</channel> 

<service-activator input-channel="input" order="1"/> 

<service-activator input-channel="input" order="2"/> 

는 항상 먼저 호출됩니다. 첫 번째 오류가 발생하는 경우에만 두 번째 오류가 발생합니다.

failover은 기본적으로 입니다.

+0

만 삼년 후반) RabbitMQ 요즘으로 Spring 통합을 사용하여 이전. – DeliveryNinja

관련 문제