当前位置: 首页>>代码示例>>Java>>正文


Java SpringRouteBuilder类代码示例

本文整理汇总了Java中org.apache.camel.spring.SpringRouteBuilder的典型用法代码示例。如果您正苦于以下问题:Java SpringRouteBuilder类的具体用法?Java SpringRouteBuilder怎么用?Java SpringRouteBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SpringRouteBuilder类属于org.apache.camel.spring包,在下文中一共展示了SpringRouteBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
    return new SpringRouteBuilder() {
        public void configure() {
            from("direct:start")
                .pollEnrich().simple("jpa://" + Customer.class.getName() + "?query=select c from Customer c where c.name like '${header.name}'")
                    .aggregationStrategy((a, b) -> {
                        String name = b.getIn().getBody(Customer.class).getName();
                        String phrase = a.getIn().getBody(String.class).replace("NAME", name);
                        a.getIn().setBody(phrase);
                        return a;
                    })
                .to("mock:result");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JpaPollingConsumerTest.java

示例2: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
    return new SpringRouteBuilder() {
        public void configure() {
            from("direct:start")
                .pollEnrich().simple("jpa://" + Customer.class.getName() + "?query=select c from Customer c where c.name like '${header.name}'")
                    .timeout(5000)
                    .aggregationStrategy((a, b) -> {
                        String name = b.getIn().getBody(Customer.class).getName();
                        String phrase = a.getIn().getBody(String.class).replace("NAME", name);
                        a.getIn().setBody(phrase);
                        return a;
                    })
                .to("mock:result");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:JpaPollingConsumerTimeoutTest.java

示例3: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
    return new SpringRouteBuilder() {
        public void configure() {

            from("direct:start")
                .to("jpa://" + SendEmail.class.getName())
                .wireTap("direct:tap")
                .to("mock:result");

            from("direct:tap")
                .delay(constant("1000"))
                .setBody(constant(new SendEmail("[email protected]")))
                .to("jpa://" + SendEmail.class.getName())
                .to("mock:result");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:JpaWireTapTest.java

示例4: testRollbackUsingXmlQueueToQueue

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
@Test
public void testRollbackUsingXmlQueueToQueue() throws Exception {

    // configure routes and add to camel context
    context.addRoutes(new SpringRouteBuilder() {

        @Override
        public void configure() throws Exception {
            Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);
            from("activemq:queue:foo?transacted=true").policy(required).process(new ConditionalExceptionProcessor())
                .to("activemq:queue:bar?transacted=true");
        }
    });

    assertResult();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:QueueToQueueTransactionTest.java

示例5: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // use required as transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // configure to use transaction error handler and pass on the required as it will fetch
            // the transaction manager from it that it needs
            errorHandler(transactionErrorHandler(required));

            // on exception is also supported
            onException(IllegalArgumentException.class).handled(false).to("mock:error").rollback();

            from("direct:okay")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:TransactionalClientDataSourceWithOnExceptionRollbackTest.java

示例6: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // START SNIPPET: e1

            // on exception is also supported
            // so if an IllegalArgumentException is thrown then we route it to the mock:error
            // since we mark it as handled then the exchange will NOT rollback
            onException(IllegalArgumentException.class).handled(true).to("mock:error");

            from("direct:okay")
                // mark this route as transacted
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                // mark this route as transacted
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
            // END SNIPPET: e1
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:TransactionalClientDataSourceHandledTest.java

示例7: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            onException(IllegalArgumentException.class).maximumRedeliveries(3);

            // START SNIPPET: e1
            from("direct:okay")
                // marks this route as transacted, and we dont pass in any parameters so we
                // will auto lookup and use the Policy defined in the spring XML file
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            // marks this route as transacted that will use the single policy defined in the registry
            from("direct:fail")
                // marks this route as transacted, and we dont pass in any parameters so we
                // will auto lookup and use the Policy defined in the spring XML file
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
            // END SNIPPET: e1
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:TransactionalClientDataSourceOnExceptionRedeliveryTest.java

示例8: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // START SNIPPET: e1

            // on exception is also supported
            // so if an IllegalArgumentException is thrown then we route it to the mock:error
            // since we have handled = false then the exception is not handled and Camel will
            // rollback
            onException(IllegalArgumentException.class).handled(false).to("mock:error");

            from("direct:okay")
                // mark this route as transacted
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                // mark this route as transacted
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
            // END SNIPPET: e1
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:TransactionalClientDataSourceWithOnExceptionMinimalConfigurationTest.java

示例9: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // ignore failure if its something with Donkey
            onException(IllegalArgumentException.class).onWhen(exceptionMessage().contains("Donkey")).handled(true);

            from("direct:okay")
                // mark this route as transacted
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");

            from("direct:fail")
                // and this route is not transacted
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:TransactionalClientDataSourceMixedTransactedTest.java

示例10: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            from("direct:required")
                .transacted("PROPATATION_REQUIRED")
                .bean("bookService");

            from("direct:required2")
                .transacted("PROPATATION_REQUIRED")
                .bean("bookService")
                .bean("bookService");

            from("direct:new")
                .transacted("PROPAGATION_REQUIRES_NEW")
                .bean("bookService");

            from("direct:requiredAndNew").to("direct:required", "direct:new");

            from("direct:requiredAndNewRollback")
                .to("direct:required")
                // change to donkey so it will rollback
                .setBody(constant("Donkey in Action"))
                .to("direct:new");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:MixedPropagationTransactedTest.java

示例11: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // use required as transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // configure to use transaction error handler and pass on the required as it will fetch
            // the transaction manager from it that it needs
            errorHandler(transactionErrorHandler(required));

            onException(IllegalArgumentException.class)
                    .handled(true).to("mock:error").rollback();

            from("direct:okay")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:TransactionalClientDataSourceWithOnExceptionHandledAndRollbackTest.java

示例12: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {

            from("file://target/transacted/okay")
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("file://target/transacted/fail?moveFailed=../failed")
                .onException(IllegalArgumentException.class)
                    .handled(false)
                    .to("mock:error")
                .end()
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest.java

示例13: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // START SNIPPET: e1
            // use a global transaction error handler so all routes is transacted
            errorHandler(transactionErrorHandler());

            from("direct:okay")
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            // marks this route as transacted that will use the single policy defined in the registry
            from("direct:fail")
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
            // END SNIPPET: e1
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:TransactionalClientDataSourceTransactionErrorHandlerTest.java

示例14: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    // Notice that we use the SpringRouteBuilder that has a few more features than
    // the standard RouteBuilder
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // setup the transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // use transaction error handler
            errorHandler(transactionErrorHandler(required));

            // must setup policy for each route
            from("direct:okay").policy(required)
                    .setBody(constant("Tiger in Action")).bean("bookService")
                    .setBody(constant("Elephant in Action")).bean("bookService");

            // must setup policy for each route
            from("direct:fail").policy(required)
                    .setBody(constant("Tiger in Action")).bean("bookService")
                    // force a rollback
                    .rollback();
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:TransactionalClientWithRollbackTest.java

示例15: createRouteBuilder

import org.apache.camel.spring.SpringRouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            onException(IllegalArgumentException.class)
                    .handled(true).to("mock:error").transform(constant("Sorry")).markRollbackOnly();

            from("direct:okay")
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .transacted()
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:TransactionalClientDataSourceWithOnExceptionHandledAndRollbackUsingTransactedTest.java


注:本文中的org.apache.camel.spring.SpringRouteBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。