當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。