Package org.apache.camel.spi

Examples of org.apache.camel.spi.Policy


        }

        // no explicit reference given from user so we can use some convention over configuration here

        // try to lookup by scoped type
        Policy answer = null;
        if (type != null) {
            // try find by type, note that this method is not supported by all registry
            Map<String, ?> types = routeContext.lookupByType(type);
            if (types.size() == 1) {
                // only one policy defined so use it
View Full Code Here


    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = createOutputsProcessor(routeContext);

        Policy policy = resolvePolicy(routeContext);
        ObjectHelper.notNull(policy, "policy", this);
        return policy.wrap(routeContext, childProcessor);
    }
View Full Code Here

        }

        // no explicit reference given from user so we can use some convention over configuration here

        // try to lookup by scoped type
        Policy answer = null;
        if (type != null) {
            // try find by type, note that this method is not supported by all registry
            Map types = routeContext.lookupByType(type);
            if (types.size() == 1) {
                // only one policy defined so use it
View Full Code Here

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = createOutputsProcessor(routeContext);

        Policy policy = resolvePolicy(routeContext);
        ObjectHelper.notNull(policy, "policy", this);
        return policy.wrap(routeContext, childProcessor);
    }
View Full Code Here

                SpringTransactionPolicy requried = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRED", TransactionTemplate.class));
                SpringTransactionPolicy notsupported = new SpringTransactionPolicy(lookup("PROPAGATION_NOT_SUPPORTED", TransactionTemplate.class));
                SpringTransactionPolicy requirenew = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRES_NEW", TransactionTemplate.class));

                Policy rollback = new Policy() {
                    public Processor wrap(RouteContext routeContext, Processor processor) {
                        return new DelegateProcessor(processor) {
                            @Override
                            public void process(Exchange exchange) throws Exception {
                                processNext(exchange);
                                throw new RuntimeException("rollback");
                            }

                            @Override
                            public String toString() {
                                return "rollback(" + getProcessor() + ")";
                            }
                        };
                    }
                };

                Policy catchRollback = new Policy() {
                    public Processor wrap(RouteContext routeContext, Processor processor) {
                        return new DelegateProcessor(processor) {
                            @Override
                            public void process(Exchange exchange) {
                                try {
View Full Code Here

        JmsComponent c1 = (JmsComponent)context.getComponent("activemq-1");
        final ConditionalExceptionProcessor cp = new ConditionalExceptionProcessor(10);
        context.addRoutes(new SpringRouteBuilder() {
            @Override
            public void configure() throws Exception {
                Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);
                from("activemq:queue:foo?replyTo=queue:foo.reply").policy(required).process(cp).to("activemq-1:queue:bar?replyTo=queue:bar.reply");
                from("activemq-1:queue:bar").process(new Processor() {
                    public void process(Exchange e) {
                        String request = e.getIn().getBody(String.class);
                        Message out = e.getOut();
View Full Code Here

        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");
            }
        });
View Full Code Here

                SpringTransactionPolicy requried = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRED", TransactionTemplate.class));
                SpringTransactionPolicy notsupported = new SpringTransactionPolicy(lookup("PROPAGATION_NOT_SUPPORTED", TransactionTemplate.class));
                SpringTransactionPolicy requirenew = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRES_NEW", TransactionTemplate.class));

                Policy rollback = new Policy() {
                    public Processor wrap(RouteContext routeContext, Processor processor) {
                        return new DelegateProcessor(processor) {
                            @Override
                            public void process(Exchange exchange) throws Exception {
                                processNext(exchange);
                                throw new RuntimeException("rollback");
                            }

                            @Override
                            public String toString() {
                                return "rollback(" + getProcessor() + ")";
                            }
                        };
                    }
                };

                Policy catchRollback = new Policy() {
                    public Processor wrap(RouteContext routeContext, Processor processor) {
                        return new DelegateProcessor(processor) {
                            @Override
                            public void process(Exchange exchange) {
                                try {
View Full Code Here

        context.addRoutes(new SpringRouteBuilder() {

            @Override
            public void configure() throws Exception {

                Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);
                from("activemq:queue:foo").policy(required).process(new ConditionalExceptionProcessor());
            }
        });

        assertResult();
View Full Code Here

    public void testRollbackUsingXmlQueueToQueueRequestReplyUsingDynamicMessageSelector() throws Exception {
        final ConditionalExceptionProcessor cp = new ConditionalExceptionProcessor(10);
        context.addRoutes(new SpringRouteBuilder() {
            @Override
            public void configure() throws Exception {
                Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);

                from("activemq:queue:foo").policy(required).process(cp).to("activemq-1:queue:bar?replyTo=queue:bar.reply");

                from("activemq-1:queue:bar").process(new Processor() {
                    public void process(Exchange e) {
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.Policy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.