Viv*_*lan 0 activemq-classic jms apache-camel
我正在尝试在apache-camel路由中读取jms头.以下是我正在阅读正文和标题的路线.
String endPointTopic = "activemq:topic:geoLoc";
String endPointTopicOut = endPointTopic + "_outbox";
from(endPointTopic)
.log("Message from Topic is ${body} & header is ${header.Action}")
.to(endPointTopicOut);
Run Code Online (Sandbox Code Playgroud)
基本上从日志中我可以看到以下内容,这意味着我能够读取正文而不是标题中的id.
来自Topic的消息是GeoLocationInfoDTO {id = 2,geoLocationUUId ='null',geoLocationName ='null',geoLocationDesc ='null',geoLocationPolygon ='null',geoLocationCenterLatitude ='null',geoLocationCenterLongitude ='null'}&header is
以下是我通过jms模板将消息发布到activeMQ的代码.
private MessageHeaders getMessageHeaders(HttpMethod action) {
log.debug("DomainPublisher : getMessageHeaders");
Map <String, Object> headerMap = new HashMap<>();
headerMap.put("Action", action);
return new MessageHeaders(headerMap);
}
public void publish(BaseDTO dto, HttpMethod action) {
log.debug("DomainPublisher : type is : {} : ", dto.getClass().getName());
getJmsMessagingTemplate().convertAndSend(topicMap.get(dto.getClass().getName()), dto, getMessageHeaders(action));
}
Run Code Online (Sandbox Code Playgroud)
注意:我还尝试将标头ID记录为$ {header.id}而不是$ {header.Action},但没有任何内容被打印出来.
我还想知道jms消息可用的所有头文件.
您可以使用此示例中显示的所有标头和属性记录交换:
.to("log:like-to-see-all?level=INFO&showAll=true&multiline=true")
Run Code Online (Sandbox Code Playgroud)
http://camel.apache.org/log.html
有关JMS头的更多信息,请访问:http://camel.apache.org/jms.html
可能的标题列表:
| 归档时间: |
|
| 查看次数: |
3024 次 |
| 最近记录: |