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


Java RouteBuilder类代码示例

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


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

示例1: createRouteBuilder

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            from("sjms:queue:start").to("log:request")
                .to("sjms:queue:in.out.queue?exchangePattern=InOut&namedReplyTo=in.out.queue.response")
                .to("log:response").to("mock:result");

            from("sjms:queue:in.out.queue?exchangePattern=InOut").process(new Processor() {
                public void process(Exchange exchange) throws Exception {
                    String body = (String)exchange.getIn().getBody();
                    if (body.contains("Camel")) {
                        Thread.sleep(2000);
                    }
                }
            });
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:InOutConsumerQueueTest.java

示例2: createSyndesisRouteBuilder

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
protected RouteBuilder createSyndesisRouteBuilder() {
    return new SyndesisRouteBuilder("") {
        @Override
        protected SyndesisModel loadModel() throws Exception {
            SyndesisModel syndesis = new SyndesisModel();
            syndesis.createFlow()
                .addStep(new Endpoint("direct:extension"))
                .addStep(new Function()
                    .name(MyExtension.class.getName())
                    .property("message", "hello"))
                .addStep(new Endpoint("direct:a/b"));

            return syndesis;
        }
    };
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:FunctionTest.java

示例3: mapBeanRoutes

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
public static RoutesBuilder mapBeanRoutes(ServiceRepository serviceRepository,
                                          Service service) {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            List<Method> methods = javaslang.collection.List.of(service.getConfiguration().getServiceClass().getDeclaredMethods());

            // create an instance of the bean
            Object beanToUse = service.getConfiguration().getTargetBean();

            for (Method m : methods) {
                if (Modifier.isPublic(m.getModifiers())) {
                    from("direct:" + formatBeanMethodRoute(m))
                            .bean(beanToUse, formatBeanEndpointRoute(m), true);
                }
            }
        }
    };
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:20,代码来源:RouteBuilders.java

示例4: mapBeanClassRoutes

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
public static RouteBuilder mapBeanClassRoutes(DrinkWaterApplication app, Service service) {

        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                List<Method> methods = javaslang.collection.List.of(service.getConfiguration().getServiceClass().getDeclaredMethods());

                // create an instance of the bean
                Object beanToUse = BeanFactory.createBeanClass(app, service.getConfiguration(), service);

                for (Method m : methods) {
                    if (Modifier.isPublic(m.getModifiers())) {
                        RouteDefinition def = from("direct:" + formatBeanMethodRoute(m));
                        def = addMethodInvokedStartTrace(service, def, Operation.of(m));
                        def.bean(beanToUse, formatBeanEndpointRoute(m), true);
                        addMethodInvokedEndTrace(service, def);

                    }
                }
            }
        };
    }
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:23,代码来源:RouteBuilders.java

示例5: myAction

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
@SyndesisExtensionAction(
    id = "my-step",
    name = "My Step",
    description = "A simple step",
    entrypoint = "direct:my-step"
)
public RouteBuilder myAction() {
    return new RouteBuilder() {
        @Override
        public void configure() {
            from("direct:my-step")
                .log("Body is: ${body}");
        }
    };
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:__extension-name__Extension.java

示例6: createSyndesisRouteBuilder

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
protected RouteBuilder createSyndesisRouteBuilder() {
    return new SyndesisRouteBuilder("") {
        @Override
        protected SyndesisModel loadModel() throws Exception {
            SyndesisModel syndesis = new SyndesisModel();
            syndesis.createFlow()
                .addStep(new Endpoint("direct:extension"))
                .addStep(new Extension()
                    .name(MyExtension.class.getName())
                    .property("message", "hello"))
                .addStep(new Endpoint("direct:a/b"));

            return syndesis;
        }
    };
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:ExtensionTest.java

示例7: consumerRoute

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
/**
 * Camel routes that use the engine as a consumer (directly or indirectly).
 *
 * @return route builder.
 */
@Bean
public RouteBuilder consumerRoute() {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            // @formatter:off
            from("sponge:camelRssEngine").routeId("spongeConsumer")
                    .log("Received Camel message: ${body}");

            from("direct:log").routeId("directLog")
                    .log("${body}");
            // @formatter:on
        }
    };
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:22,代码来源:SpringConfiguration.java

示例8: route

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
@Override
public RouteBuilder route() {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            // @formatter:off
            from("direct:start").routeId("spongeProducer")
                    .to("sponge:spongeEngine?action=CustomAction&managed=false")
                    .log("Action result as a body: ${body}")
                    .to("direct:log");

            from("direct:log").routeId("directLog")
                    .log("Action result as a body: ${body}");
            // @formatter:on
        }
    };
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:20,代码来源:CamelProducerCustomUriActionTest.java

示例9: route

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
@Override
public RouteBuilder route() {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            // @formatter:off
            from("sponge:spongeEngine").routeId("spongeConsumer1")
                    .to("direct:log");

            from("sponge:spongeEngine").routeId("spongeConsumer2")
                    .to("direct:log");

            from("direct:log").routeId("directLog")
                    .log("${body}");
            // @formatter:on
        }
    };
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:21,代码来源:CamelManyConsumersTest.java

示例10: exampleRoute

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
public RouteBuilder exampleRoute() {
    return new RouteBuilder() {

        @Override
        public void configure() {
            // @formatter:off
            from("sponge:spongeEngine").routeId("spongeConsumer")
                .log("${body}")
                .process(exchange -> spongeEngine().getOperations().getVariable(AtomicBoolean.class, "receivedCamelMessage")
                        .set(true))
                .to("stream:out");
            // @formatter:on
        }
    };
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:17,代码来源:SimpleCamelConsumerTest.java

示例11: route

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
@Override
public RouteBuilder route() {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            // @formatter:off
            from("direct:start").routeId("spongeProducer")
                    .setHeader("CamelSpongeAction", constant("CustomAction"))
                    .to("sponge:spongeEngine?managed=false")
                    .log("Action result as a body: ${body}")
                    .to("direct:log");

            from("direct:log").routeId("directLog")
                    .log("Action result as a body: ${body}");
            // @formatter:on
        }
    };
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:21,代码来源:CamelProducerCustomHeaderActionTest.java

示例12: createSoapService

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
public RouteBuilder createSoapService() {
	return new RouteBuilder() {
		@Override
		public void configure() throws Exception {
			from("cxf:/GlobalWeather?serviceClass=" + GlobalWeatherSoap.class.getName())
					.routeId("test-GlobalWeatherSoap")
					.toD("direct:${header." + CxfConstants.OPERATION_NAME + "}");

			from("direct:GetCitiesByCountry")
				.setProperty("country",simple("${body[0]}",String.class)) //The method arguments are in a org.apache.cxf.message.MessageContentsList
				.process((e) -> {
					switch(e.getProperty("country",String.class)) {
					case "TEST":
						e.getIn().setBody("<NewDataSet><Table><Country>TEST</Country><City>AA</City></Table><Table><Country>TEST</Country><City>BB</City></Table></NewDataSet>");
						break;
					default:
						e.getIn().setBody("<NewDataSet/>");
					}
				});

		}

	};
}
 
开发者ID:bszeti,项目名称:camel-springboot,代码行数:26,代码来源:SoapCallWithObjectTest.java

示例13: createSoapService

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Bean
public RouteBuilder createSoapService() {
	return new RouteBuilder() {
		@Override
		public void configure() throws Exception {
			from("cxf:/GlobalWeather?dataFormat=MESSAGE")
					.routeId("test-GlobalWeatherSoap")
					.choice()
					.when(header(SoapBindingConstants.SOAP_ACTION).contains("GetCitiesByCountry"))
						.process((e) -> {
							e.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, getCitiesByCountryResponseCode);
							e.getIn().setBody(getClass().getClassLoader().getResourceAsStream(getCitiesByCountryResponseResource));
							
						})
					.end()
					;
		}
	};
}
 
开发者ID:bszeti,项目名称:camel-springboot,代码行数:20,代码来源:SoapCallWithFileTest.java

示例14: shouldWrapIntegersIntoCamelBodies

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Test
public void shouldWrapIntegersIntoCamelBodies(TestContext context) throws Exception {
    Async async = context.async();
    CamelSink<Integer> sink = new CamelSink<>(
            new JsonObject().put("endpoint", "direct:test")
    );
    CamelContext camelContext = sink.camelContext();
    camelContext.addRoutes(new RouteBuilder() {

        @Override public void configure() throws Exception {
            from("direct:test").process(event -> {
                if (event.getIn().getBody(Integer.class) == 10) {
                    context.assertEquals(event.getIn().getBody(Integer.class), 10);
                    async.complete();
                }
            });
        }
    });

    Source.from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).to(sink);
}
 
开发者ID:cescoffier,项目名称:fluid,代码行数:22,代码来源:CamelSinkTest.java

示例15: createRouteBuilder

import org.apache.camel.builder.RouteBuilder; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() {
			Map<String, String> properties = context.getProperties();
			properties.put(OrientDBComponent.DB_URL, DB_URL);
			properties.put(OrientDBComponent.DB_USERNAME, DB_USERNAME);
			properties.put(OrientDBComponent.DB_PASSWORD, DB_PASSWORD);
			context.setProperties(properties);

			from("orientdb:INSERT INTO "+TEST_LINKED_CLASS+" SET "+TEST_PROPERTY+"=\""+TEST_PROPERTY_VALUE+"\"?outputType=map&preload=false")
			.to("orientdb:INSERT INTO "+TEST_CLASS+" SET "+TEST_PROPERTY+"=\""+TEST_PROPERTY_VALUE+"\", "+TEST_LINK_PROPERTY+"=:rid")
			.to("orientdb:?preload=true&makeNew=true")
           	.to("mock:result");
        }
    };
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:18,代码来源:OrientDBComponentTest.java


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