简体   繁体   English

如何在 spring 集成消息中设置 JMS Header

[英]How to set JMS Header in spring integration message

I am trying to set jms correlation id in spring integration message by setting in its header before pushing into a IBM MQ but the value Is not available after reading the message from the queue.我试图在 spring 集成消息中设置 jms 相关 ID,方法是在推入 IBM MQ 之前在其 header 中设置,但在从队列中读取消息后该值不可用。

Using the below code to set the header使用以下代码设置 header

MessageBuilder.withPayload("Hi")
.setHeader(JmsConstans.JMS_CORRELATIONID,"ID12334556889").build();

We don't know what is that JmsConstans.JMS_CORRELATIONID : it is not available in my dependencies.我们不知道JmsConstans.JMS_CORRELATIONID是什么:它在我的依赖项中不可用。 So, sounds more like it is your own and, therefore, we have to know its value.所以,听起来更像是你自己的,因此,我们必须知道它的价值。

The logic in the DefaultJmsHeaderMapper (used by default by the JmsSendingMessageHandler ) is like this: DefaultJmsHeaderMapper中的逻辑(默认情况下由JmsSendingMessageHandler使用)是这样的:

private void populateCorrelationIdPropertyFromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) {
    Object jmsCorrelationId = headers.get(JmsHeaders.CORRELATION_ID);
    if (jmsCorrelationId instanceof Number) {
        jmsCorrelationId = jmsCorrelationId.toString();
    }
    if (jmsCorrelationId instanceof String) {
        try {
            jmsMessage.setJMSCorrelationID((String) jmsCorrelationId);
        }
        catch (Exception ex) {
            LOGGER.info("Failed to set JMSCorrelationID, skipping", ex);
        }
    }
}

where that JmsHeaders.CORRELATION_ID has this value: jms_correlationId .其中JmsHeaders.CORRELATION_ID具有以下值: jms_correlationId

However all of this is just a speculation since e don't know how you push that message to IBM MQ...然而,所有这一切都只是一种推测,因为我们不知道您如何将该消息推送到 IBM MQ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Spring Integration的Message标头中设置文件名 - Set File name in Message header in Spring Integration Spring集成中如何将XML JMS消息发送到FTP - How to send XML JMS message to FTP in Spring integration 如何将 ConnectionFactory 类设置为 Jms outboundAdapter? (在 Spring Integration 中) - How to set a ConnectionFactory class to an Jms outboundAdapter? (within Spring Integration) 如何在 Spring Integration 中设置肥皂头? - How to set soap header in Spring Integration? 如何在Spring Integration DSL中基于消息ID丰富消息头? - How to enrich message header based on message id in spring integration DSL? Web 服务将 Soap 消息放入队列中,并带有 Spring 集成和 Jms - Web service putting Soap message in queue with Spring Integration and Jms 是否可以从队列弹簧集成中清除特定的jms消息? - Is it possible purge specific jms message from queue spring integration? 使用选择器的Spring Integration JMS消息驱动的通道适配器 - spring integration JMS message driven channel adaptor using selector 如何从 Spring JMS 侦听器中的 JMS 消息获取自定义属性 - How to get custom properties from JMS message in a Spring JMS Listener 如何在 spring 集成 DSL 中为通道设置多个消息处理程序? - How to set several message handlers for channel in spring integration DSL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM