本文整理匯總了Java中org.apache.camel.CamelContext.createProducerTemplate方法的典型用法代碼示例。如果您正苦於以下問題:Java CamelContext.createProducerTemplate方法的具體用法?Java CamelContext.createProducerTemplate怎麽用?Java CamelContext.createProducerTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.CamelContext
的用法示例。
在下文中一共展示了CamelContext.createProducerTemplate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCamelProducer
import org.apache.camel.CamelContext; //導入方法依賴的package包/類
@Test
public void testCamelProducer() throws Exception {
// Starting Spring context.
try (GenericApplicationContext context = new AnnotationConfigApplicationContext(ExampleConfiguration.class)) {
context.start();
// Sending Camel message.
CamelContext camel = context.getBean(CamelContext.class);
ProducerTemplate producerTemplate = camel.createProducerTemplate();
producerTemplate.sendBody("direct:start", "Send me to the Sponge");
// Waiting for the engine to process an event.
Engine engine = context.getBean(Engine.class);
await().atMost(60, TimeUnit.SECONDS)
.until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "sentCamelMessage").get());
assertFalse(engine.isError());
context.stop();
}
}
示例2: testCamelProducerOverridenAction
import org.apache.camel.CamelContext; //導入方法依賴的package包/類
@Test
public void testCamelProducerOverridenAction() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
Engine engine = DefaultEngine.builder().knowledgeBase("camelkb", "examples/camel/camel_producer_overridden_action.py").build();
registry.put("spongeEngine", engine);
CamelContext camel = new DefaultCamelContext(registry);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() {
// @formatter:off
from("direct:start").routeId("spongeProducer")
.to("sponge:spongeEngine");
// @formatter:on
}
});
camel.start();
try {
ProducerTemplate producerTemplate = camel.createProducerTemplate();
producerTemplate.sendBody("direct:start", "Send me to the Sponge");
await().pollDelay(2, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS)
.until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "sentCamelMessage_camelEvent").get());
assertFalse(engine.getOperations().getVariable(AtomicBoolean.class, "sentCamelMessage_spongeProducer").get());
assertFalse(engine.isError());
} finally {
camel.stop();
}
}
示例3: testCamelProducer
import org.apache.camel.CamelContext; //導入方法依賴的package包/類
@Test
public void testCamelProducer() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
Engine engine = DefaultEngine.builder().knowledgeBase("camelkb", "examples/camel/camel_producer.py").build();
registry.put("spongeEngine", engine);
CamelContext camel = new DefaultCamelContext(registry);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() {
// @formatter:off
from("direct:start").routeId("spongeProducer")
.to("sponge:spongeEngine");
// @formatter:on
}
});
camel.start();
try {
ProducerTemplate producerTemplate = camel.createProducerTemplate();
producerTemplate.sendBody("direct:start", "Send me to the Sponge");
await().atMost(10, TimeUnit.SECONDS)
.until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "sentCamelMessage").get());
} finally {
camel.stop();
}
}
示例4: BeanClassInvocationHandler
import org.apache.camel.CamelContext; //導入方法依賴的package包/類
public BeanClassInvocationHandler(CamelContext context) {
this.producerTemplate = context.createProducerTemplate();
}