當前位置: 首頁>>代碼示例>>Java>>正文


Java CamelContext.createProducerTemplate方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:21,代碼來源:SimpleCamelProducerTest.java

示例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();
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:34,代碼來源:CamelProducerOverriddenActionTest.java

示例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();
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:31,代碼來源:SimpleCamelNoSpringTest.java

示例4: BeanClassInvocationHandler

import org.apache.camel.CamelContext; //導入方法依賴的package包/類
public BeanClassInvocationHandler(CamelContext context) {
    this.producerTemplate = context.createProducerTemplate();
}
 
開發者ID:drinkwater-io,項目名稱:drinkwater-java,代碼行數:4,代碼來源:BeanClassInvocationHandler.java


注:本文中的org.apache.camel.CamelContext.createProducerTemplate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。