192.5. 使用例
192.5.1. 例 1: Consuming
from("kestrel://kserver02:22133/massive?concurrentConsumers=10&waitTimeMs=500") .bean("myConsumer", "onMessage");
public class MyConsumer { public void onMessage(String message) { ... } }
192.5.2. 例 2: Producing
public class MyProducer { @EndpointInject(uri = "kestrel://kserver01:22133,kserver02:22133/myqueue") ProducerTemplate producerTemplate; public void produceSomething() { producerTemplate.sendBody("Hello, world."); } }
192.5.3. 例 3: Spring XML 設定
<camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="kestrel://ks01:22133/sequential?concurrentConsumers=1&waitTimeMs=500"/> <bean ref="myBean" method="onMessage"/> </route> <route> <from uri="direct:start"/> <to uri="kestrel://ks02:22133/stuff"/> </route> </camelContext>
public class MyBean { public void onMessage(String message) { ... } }