org.apache.camel.FluentProducerTemplate Java Examples
The following examples show how to use
org.apache.camel.FluentProducerTemplate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelProducers.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Produces FluentProducerTemplate camelFluentProducerTemplate(InjectionPoint injectionPoint) { final FluentProducerTemplate template = this.context.createFluentProducerTemplate(); final Produce produce = injectionPoint.getAnnotated().getAnnotation(Produce.class); if (ObjectHelper.isNotEmpty(produce) && ObjectHelper.isNotEmpty(produce.value())) { template.setDefaultEndpointUri(produce.value()); } return template; }
Example #2
Source File: CamelSpringBootTemplateShutdownTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Before public void setupApplicationContext() { applicationContext = new AnnotationConfigApplicationContext(CamelAutoConfiguration.class); camelContext = applicationContext.getBean(CamelContext.class); consumerTemplate = applicationContext.getBean(ConsumerTemplate.class); producerTemplate = applicationContext.getBean(ProducerTemplate.class); fluentProducerTemplate = applicationContext.getBean(FluentProducerTemplate.class); }
Example #3
Source File: CamelFirstTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Test public void testCamelFirst() throws Exception { LOG.info("Starting RX-Java2 Flowable Camel first"); // create Camel CamelContext camel = new DefaultCamelContext(); // create Reative Camel CamelReactiveStreamsService rsCamel = CamelReactiveStreams.get(camel); camel.start(); rsCamel.start(); // create a publisher from Camel seda:words endpoint Publisher<String> publisher = rsCamel.from("seda:words", String.class); Flowable.fromPublisher(publisher) // upper case the word .map(w -> w.toUpperCase()) // log the big number .doOnNext(w -> LOG.info(w)) .subscribe(); // send some words to Camel FluentProducerTemplate template = camel.createFluentProducerTemplate(); template.withBody("Camel").to("seda:words").send(); template.withBody("rocks").to("seda:words").send(); template.withBody("streams").to("seda:words").send(); template.withBody("as").to("seda:words").send(); template.withBody("well").to("seda:words").send(); // sleep a bit for reactive subscriber to complete Thread.sleep(1000); camel.stop(); rsCamel.stop(); }
Example #4
Source File: AtomixMapIntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Test public void testPutAndGet() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { public void configure() { from("direct:start").toF("atomix-map:%s", MAP_NAME); } }); final String key = camelctx.getUuidGenerator().generateUuid(); final String val = camelctx.getUuidGenerator().generateUuid(); AtomixMapComponent component = camelctx.getComponent("atomix-map", AtomixMapComponent.class); component.setNodes(Collections.singletonList(replicaAddress)); camelctx.start(); try { Message result; FluentProducerTemplate fluent = camelctx.createFluentProducerTemplate().to("direct:start"); result = fluent.clearAll() .withHeader(AtomixClientConstants.RESOURCE_ACTION, AtomixMap.Action.PUT) .withHeader(AtomixClientConstants.RESOURCE_KEY, key) .withBody(val) .request(Message.class); Assert.assertFalse(result.getHeader(AtomixClientConstants.RESOURCE_ACTION_HAS_RESULT, Boolean.class)); Assert.assertEquals(val, result.getBody()); Assert.assertEquals(val, map.get(key).join()); result = fluent.clearAll() .withHeader(AtomixClientConstants.RESOURCE_ACTION, AtomixMap.Action.GET) .withHeader(AtomixClientConstants.RESOURCE_KEY, key) .request(Message.class); Assert.assertTrue(result.getHeader(AtomixClientConstants.RESOURCE_ACTION_HAS_RESULT, Boolean.class)); Assert.assertEquals(val, result.getBody(String.class)); Assert.assertTrue(map.containsKey(key).join()); } finally { camelctx.close(); } }