简体   繁体   English

Camel ProducerTemplate发送到JMS消息属性

[英]Camel ProducerTemplate send to a JMS message property

In my camel project, i need to send some message to a gateway (which will receive it as a JMS message). 在我的camel项目中,我需要向网关发送一些消息(它将作为JMS消息接收它)。

For gateway, besides the message text, there will be some other string properties using jmsMessage.getStringProperty("xxx"); 对于网关,除了消息文本之外,还有一些其他字符串属性使用jmsMessage.getStringProperty("xxx");

In my camel project, my code is something like below: 在我的camel项目中,我的代码如下所示:

@Produce(uri = "xxx")
private ProducerTemplate template;

@Override
public void sendToQueue(String textMessage, Map<String, String> properties) {
    template.sendBody(textMessage);
}

I know if I just send a string text message I will invoke the sendBody method which receive one argument. 我知道如果我只发送一个字符串文本消息,我将调用sendBody方法接收一个参数。 I just wondering how should I sent the properties using camel and on the other side they can receive the properties as JMS TextMessage string properties. 我只是想知道我应该如何使用camel发送属性,另一方面他们可以接收属性作为JMS TextMessage字符串属性。

Also what's the meaning for camel headers, it's also a map. 还有什么是驼峰标题的含义,它也是一张地图。

You can use 您可以使用

template.sendBodyAndHeaders(textMessage, properties);

As JMS properties is mapped to Camel Message headers. 由于JMS属性映射到Camel消息头。 And hence why you can use the sendBodyAndHeaders method to include the JMS properties. 因此,您可以使用sendBodyAndHeaders方法来包含JMS属性。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM