spring集成jms可追溯性



我们需要在基于Spring Integration的控制器模块中添加传入和传出JMS消息的可跟踪性(添加跟踪id和拼写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"/>

感谢

两侧都有一个带有此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-idspell-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接收之前/之后记录这些头。

最新更新