4.6. Message Translator
来源:互联网 发布:淘宝评价如何上传视频 编辑:程序博客网 时间:2024/06/14 07:50
Overview
The message translator pattern, shown in Figure 4.8, “Message Translator Pattern” describes a component that modifies the contents of a message, translating it to a different format. You can use Apache Camel’s bean integration feature to perform the message translation.
Figure 4.8. Message Translator Pattern
Bean integration
You can transform a message using bean integration, which enables you to call a method on any registered bean. For example, to call the method, myMethodName(), on the bean with ID, myTransformerBean:
from("activemq:SomeQueue") .beanRef("myTransformerBean", "myMethodName") .to("mqseries:AnotherQueue");
Where the myTransformerBean bean is defined in either a Spring XML file or in JNDI. If, you omit the method name parameter from beanRef(), the bean integration will try to deduce the method name to invoke by examining the message exchange.
You can also add your own explicit Processor instance to perform the transformation, as follows:
from("direct:start").process(new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); in.setBody(in.getBody(String.class) + " World!"); }}).to("mock:result");
Or, you can use the DSL to explicitly configure the transformation, as follows:
from("direct:start").setBody(body().append(" World!")).to("mock:result");
You can also use templating to consume a message from one destination, transform it with something like Velocity or XQuery and then send it on to another destination. For example, using the InOnly exchange pattern (one-way messaging) :
from("activemq:My.Queue"). to("velocity:com/acme/MyResponse.vm"). to("activemq:Another.Queue");
If you want to use InOut (request-reply) semantics to process requests on the My.Queue queue on ActiveMQ with a template generated response, then you could use a route like the following to send responses back to the JMSReplyTo destination:
from("activemq:My.Queue"). to("velocity:com/acme/MyResponse.vm");
- 4.6. Message Translator
- Message Translator
- Message Translator
- Life Translator 2.7.8.551
- SQL::Translator 学习
- Translator in HiveMind
- Translator in HiveMind
- Web Translator v8.0
- Ace Translator v4.2
- Ace Translator 4.2
- 使用自己的translator
- Web Translator v8.01
- POJ2121 Inglish-Number Translator
- GlusterFS Translator API介绍
- MOQL—转换器(Translator)
- UVa486 - English-Number Translator
- GlusterFS Translator API
- GlusterFS Translator API
- 我的linux学习笔记
- web数据传输只有两种格式:json和xml
- linux关机命令-shutdown
- 【hihocoder [Offer收割]编程练习赛9 D】【简单DP】矩阵填数
- Ubuntu上安装Docker及其基本用法
- 4.6. Message Translator
- 数据结构与程序设计 看不懂的地方汇总
- [Android] 使用ADB时提示opendir failed, Permission denied的解决方法
- 杭电 2040 亲和数
- Chapter 5. Messaging Channels
- eclipse的MyGeneration自动生成代码
- 二叉树的构建和前中后序遍历
- 5.1. Point-to-Point Channel
- 机器学习/深度学习/自然语言处理学习路线 Stanford机器学习笔记 TensorFlow人工智能引擎入门教程之系列