我们需要在基于Spring Integration的控制器模块中增加传入和传出JMS消息的可追溯性(添加trace-id和spell-id)。谁能帮助我使用可用于此目的的拦截器,该拦截器可以拦截进入JMS队列的所有请求以及将发送到队列的所有请求。
下面是代码段:
<!-- Need to trace the message once we receive in incoming_queue -->
<int-jms:message-driven-channel-adapter id="jmsIn" channel="channel_1"
destination-name="incoming_queue"></int-jms:message-driven-channel-adapter>
<!-- Need to trace the message before we send the message to outgoing_queue -->
<int-jms:outbound-channel-adapter id="jmsOut"
channel="channel_1" connection-factory="connectionFactory"
destination-name="outgoing_queue"/>
谢谢
答案 0 :(得分:0)
在此JavaDoc的两边都有DefaultJmsHeaderMapper
:
* This implementation copies JMS API headers (e.g. JMSReplyTo) to and from
* Spring Integration Messages. Any user-defined properties will also be copied
* from a JMS Message to a Spring Integration Message, and any other headers
* on a Spring Integration Message (beyond the JMS API headers) will likewise
* be copied to a JMS Message. Those other headers will be copied to the
* general properties of a JMS Message whereas the JMS API headers are passed
* to the appropriate setter methods (e.g. setJMSReplyTo).
因此,如果您的trace-id
和spell-id
处于兼容类型:
private static List<Class<?>> SUPPORTED_PROPERTY_TYPES = Arrays.asList(new Class<?>[] {
Boolean.class, Byte.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class });
您很好发送和接收这些标头。
如果您想记录日志头之类的东西,您肯定可以看看ChannelInterceptor
实现,以便在向JMS发送/从JMS接收之前/之后记录这些头。