本文整理汇总了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);
}
}
});
}
};
}
示例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;
}
};
}
示例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);
}
}
}
};
}
示例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);
}
}
}
};
}
示例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}");
}
};
}
示例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;
}
};
}
示例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
}
};
}
示例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
}
};
}
示例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
}
};
}
示例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
}
};
}
示例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
}
};
}
示例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/>");
}
});
}
};
}
示例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()
;
}
};
}
示例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);
}
示例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");
}
};
}