【问题标题】:How to intercept the reply message of an jms inbound gateway如何拦截一个jms入站网关的回复消息
【发布时间】:2015-02-27 01:20:15
【问题描述】:

我有一个 jms-inbound-gateway,它从 WebsphereMQ 代理读取请求,将它们传递给我的集成系统,然后回复一条响应消息。

我需要记录设置了 jms_messageId 和 jms_correlationId 标头的消息,因此我可以匹配日志文件中的请求/回复消息(并在我的客户说我的响应没有正确的 jms_correlationId 时将其显示给我)

有没有办法在correlationId头设置后拦截方法producer.sendReply(...)?

【问题讨论】:

    标签: jms spring-integration gateway inbound


    【解决方案1】:

    那里不需要拦截;标头在到达网关之前在网关回复消息中的 Spring Integration 消息中可用。

    只需将reply-channel 设为publish-subscribe-channel 并添加一个将其作为输入通道的<logging-channel-adapter/>

    回复消息将同时发送到网关和记录器。

    如果您使用默认机制来路由回复(最后一个集成组件上没有output-channel),只需添加一个output-channel 并路由到回复通道。

    【讨论】:

    • 你是个天才!像魅力一样工作(花了我一段时间,因为我不知道reply-channel 属性)。谢谢加里
    【解决方案2】:

    这是 Gary 输入后我的解决方案的要点:

    <jms:inbound-gateway 
        id="inboundDestination" 
        connection-factory="connectionFactory"  
        request-destination="nmRequestsQueue" 
        request-channel="request-begin" 
        reply-channel="request-end" 
        error-channel="normaErrorChannel" 
        concurrent-consumers="1" 
        acknowledge="transacted" />
    
    <int:logging-channel-adapter id="request-response-logger"
            log-full-message="true"
            level="DEBUG" 
            logger-name="com.audaxys.si.messages" />
    
    <int:channel id="request-begin">
        <int:interceptors>
            <int:wire-tap channel="request-response-logger" />
        </int:interceptors>
    </int:channel>
    
    <int:chain input-channel="request-begin" output-channel="request-end">
        ... Do Stuff ...
    </int:chain>
    
    <int:publish-subscribe-channel id="request-end">
        <int:interceptors>
            <int:wire-tap channel="request-response-logger" />
        </int:interceptors>
    </int:publish-subscribe-channel>
    

    【讨论】:

    • 备案;因为您使用的是线控来记录,request-end 不必是 pub-sub;如果记录器将 request-end 作为其输入通道,则它需要是 pub-sub。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-09
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多