Java Code Examples for org.apache.camel.ProducerTemplate#send()
The following examples show how to use
org.apache.camel.ProducerTemplate#send() .
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: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/activiti5/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml"}) public void testCamelHeadersFiltered() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startFilteredHeaders").createExchange(); tpl.send("direct:startFilteredHeaders", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertEquals("sampleValueForProperty1", variables.get("property1")); assertEquals("sampleValueForProperty2", variables.get("property2")); assertNull(variables.get("property3")); }
Example 2
Source File: EmptyProcessTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "process/empty.bpmn20.xml" }) public void testObjectAsStringVariable() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); Object expectedObj = new Long(99); Exchange exchange = ctx.getEndpoint("direct:startEmptyBodyAsString").createExchange(); exchange.getIn().setBody(expectedObj); tpl.send("direct:startEmptyBodyAsString", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); assertProcessEnded(instanceId); HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult(); assertNotNull(var); assertEquals(expectedObj.toString(), var.getValue().toString()); }
Example 3
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/activiti5/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml"}) public void testCamelHeadersNone() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startNoHeaders").createExchange(); tpl.send("direct:startNoHeaders", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertNull(variables.get("property1")); assertNull(variables.get("property2")); assertNull(variables.get("property3")); }
Example 4
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/activiti5/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml"}) public void testCamelHeadersAll() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange(); tpl.send("direct:startAllProperties", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertEquals("sampleValueForProperty1", variables.get("property1")); assertEquals("sampleValueForProperty2", variables.get("property2")); assertEquals("sampleValueForProperty3", variables.get("property3")); }
Example 5
Source File: CdiSimpleProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "process/example.bpmn20.xml" }) public void testRunProcess() throws Exception { CamelContext ctx = ProgrammaticBeanLookup.lookup(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); service1.expectedBodiesReceived("ala"); Exchange exchange = ctx.getEndpoint("direct:start").createExchange(); exchange.getIn().setBody(Collections.singletonMap("var1", "ala")); tpl.send("direct:start", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(instanceId).singleResult(); assertThat(processInstance.isEnded()).isFalse(); tpl.sendBodyAndProperty("direct:receive", null, FlowableProducer.PROCESS_ID_PROPERTY, instanceId); // check process ended processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(instanceId).singleResult(); assertThat(processInstance).isNull(); service1.assertIsSatisfied(); Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class); assertThat(m.get("var1")).isEqualTo("ala"); assertThat(m.get("var2")).isEqualTo("var2"); }
Example 6
Source File: CustomContextTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "process/custom.bpmn20.xml" }) public void testRunProcess() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); service1.expectedBodiesReceived("ala"); Exchange exchange = ctx.getEndpoint("direct:start").createExchange(); exchange.getIn().setBody(Collections.singletonMap("var1", "ala")); tpl.send("direct:start", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); tpl.sendBodyAndProperty("direct:receive", null, ActivitiProducer.PROCESS_ID_PROPERTY, instanceId); assertProcessEnded(instanceId); service1.assertIsSatisfied(); @SuppressWarnings("rawtypes") Map m = service2.getExchanges().get(0).getIn().getBody(Map.class); assertEquals("ala", m.get("var1")); assertEquals("var2", m.get("var2")); }
Example 7
Source File: SimpleSpringProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "process/example.bpmn20.xml" }) public void testRunProcess() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); service1.expectedBodiesReceived("ala"); Exchange exchange = ctx.getEndpoint("direct:start").createExchange(); exchange.getIn().setBody(Collections.singletonMap("var1", "ala")); tpl.send("direct:start", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); tpl.sendBodyAndProperty("direct:receive", null, FlowableProducer.PROCESS_ID_PROPERTY, instanceId); assertProcessEnded(instanceId); service1.assertIsSatisfied(); Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class); assertThat(m.get("var1")).isEqualTo("ala"); assertThat(m.get("var2")).isEqualTo("var2"); }
Example 8
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/activiti/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml"}) public void testCamelHeadersNone() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startNoHeaders").createExchange(); tpl.send("direct:startNoHeaders", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertNull(variables.get("property1")); assertNull(variables.get("property2")); assertNull(variables.get("property3")); }
Example 9
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/activiti/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml"}) public void testCamelHeadersFiltered() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startFilteredHeaders").createExchange(); tpl.send("direct:startFilteredHeaders", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertEquals("sampleValueForProperty1", variables.get("property1")); assertEquals("sampleValueForProperty2", variables.get("property2")); assertNull(variables.get("property3")); }
Example 10
Source File: SimpleProcessTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "process/example.bpmn20.xml" }) public void testRunProcess() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); service1.expectedBodiesReceived("ala"); Exchange exchange = ctx.getEndpoint("direct:start").createExchange(); exchange.getIn().setBody(Collections.singletonMap("var1", "ala")); tpl.send("direct:start", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); tpl.sendBodyAndProperty("direct:receive", null, ActivitiProducer.PROCESS_ID_PROPERTY, instanceId); assertProcessEnded(instanceId); service1.assertIsSatisfied(); Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class); assertEquals("ala", m.get("var1")); assertEquals("var2", m.get("var2")); }
Example 11
Source File: CamelVariableTransferTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { "org/flowable/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml" }) public void testCamelHeadersAll() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange(); tpl.send("direct:startAllProperties", exchange); assertThat(taskService).isNotNull(); assertThat(runtimeService).isNotNull(); assertThat(taskService.createTaskQuery().count()).isEqualTo(1); Task task = taskService.createTaskQuery().singleResult(); assertThat(task).isNotNull(); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertThat(variables) .contains( entry("property1", "sampleValueForProperty1"), entry("property2", "sampleValueForProperty2"), entry("property3", "sampleValueForProperty3") ); }
Example 12
Source File: CamelVariableTransferTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment public void testCamelPropertiesAll() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange(); tpl.send("direct:startAllProperties", exchange); assertThat(taskService).isNotNull(); assertThat(runtimeService).isNotNull(); assertThat(taskService.createTaskQuery().count()).isEqualTo(1); Task task = taskService.createTaskQuery().singleResult(); assertThat(task).isNotNull(); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertThat(variables) .contains( entry("property1", "sampleValueForProperty1"), entry("property2", "sampleValueForProperty2"), entry("property3", "sampleValueForProperty3") ); }
Example 13
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testCamelPropertiesAll() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange(); tpl.send("direct:startAllProperties", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertEquals("sampleValueForProperty1", variables.get("property1")); assertEquals("sampleValueForProperty2", variables.get("property2")); assertEquals("sampleValueForProperty3", variables.get("property3")); }
Example 14
Source File: SimpleProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Deployment(resources = { "process/example.bpmn20.xml" }) public void testRunProcess() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); service1.expectedBodiesReceived("ala"); Exchange exchange = ctx.getEndpoint("direct:start").createExchange(); exchange.getIn().setBody(Collections.singletonMap("var1", "ala")); tpl.send("direct:start", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); tpl.sendBodyAndProperty("direct:receive", null, FlowableProducer.PROCESS_ID_PROPERTY, instanceId); assertProcessEnded(instanceId); service1.assertIsSatisfied(); Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class); assertEquals("ala", m.get("var1")); assertEquals("var2", m.get("var2")); }
Example 15
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testCamelPropertiesAll() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange(); tpl.send("direct:startAllProperties", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertEquals("sampleValueForProperty1", variables.get("property1")); assertEquals("sampleValueForProperty2", variables.get("property2")); assertEquals("sampleValueForProperty3", variables.get("property3")); }
Example 16
Source File: ManagementBusServiceImpl.java From container with Apache License 2.0 | 6 votes |
/** * Handles the response from the plug-in. If needed the response is sent back to the API. * * @param exchange to handle. */ private void handleResponse(Exchange exchange) { if (exchange == null) { return; } // Response message back to caller. final ProducerTemplate template = collaborationContext.getProducer(); final String caller = exchange.getIn().getHeader(MBHeader.APIID_STRING.toString(), String.class); if (caller == null) { // notably the Java API does not set the APIID, because it never uses the information returned. LOG.debug("Invocation was InOnly. No response message will be sent to the caller."); return; } LOG.debug("Sending response message back to api: {}", caller); exchange = template.send("direct-vm:" + caller, exchange); if (exchange.isFailed()) { LOG.error("Sending exchange message failed! {}", exchange.getException().getMessage()); } }
Example 17
Source File: SimpleSpringProcessTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "process/example.bpmn20.xml" }) public void testRunProcess() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); service1.expectedBodiesReceived("ala"); Exchange exchange = ctx.getEndpoint("direct:start").createExchange(); exchange.getIn().setBody(Collections.singletonMap("var1", "ala")); tpl.send("direct:start", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); tpl.sendBodyAndProperty("direct:receive", null, ActivitiProducer.PROCESS_ID_PROPERTY, instanceId); assertProcessEnded(instanceId); service1.assertIsSatisfied(); Map<?, ?> m = service2.getExchanges().get(0).getIn().getBody(Map.class); assertEquals("ala", m.get("var1")); assertEquals("var2", m.get("var2")); }
Example 18
Source File: InitiatorCamelCallTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testInitiatorCamelCall() throws Exception { CamelContext ctx = applicationContext.getBean(CamelContext.class); ProducerTemplate tpl = ctx.createProducerTemplate(); String body = "body text"; Exchange exchange = ctx.getEndpoint("direct:startWithInitiatorHeader").createExchange(); exchange.getIn().setBody(body); tpl.send("direct:startWithInitiatorHeader", exchange); String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY"); String initiator = (String) runtimeService.getVariable(instanceId, "initiator"); assertEquals("kermit", initiator); Object camelInitiatorHeader = runtimeService.getVariable(instanceId, "CamelProcessInitiatorHeader"); assertNull(camelInitiatorHeader); }
Example 19
Source File: CamelVariableTransferTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = {"org/activiti5/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml"}) public void testCamelPropertiesNone() throws Exception { ProducerTemplate tpl = camelContext.createProducerTemplate(); Exchange exchange = camelContext.getEndpoint("direct:startNoProperties").createExchange(); tpl.send("direct:startNoProperties", exchange); assertNotNull(taskService); assertNotNull(runtimeService); assertEquals(1, taskService.createTaskQuery().count()); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId()); assertNull(variables.get("property1")); assertNull(variables.get("property2")); assertNull(variables.get("property3")); }
Example 20
Source File: SESIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void sendSimpleMessage() throws Exception { AmazonSimpleEmailServiceClient sesClient = provider.getClient(); Assume.assumeNotNull("AWS client not null", sesClient); WildFlyCamelContext camelctx = new WildFlyCamelContext(); camelctx.getNamingContext().bind("sesClient", sesClient); camelctx.addRoutes(new RouteBuilder() { public void configure() { from("direct:start") .to("aws-ses://" + SESUtils.FROM + "?amazonSESClient=#sesClient"); } }); camelctx.start(); try { Exchange exchange = ExchangeBuilder.anExchange(camelctx) .withHeader(SesConstants.SUBJECT, SESUtils.SUBJECT) .withHeader(SesConstants.TO, Collections.singletonList(SESUtils.TO)) .withBody("Hello world!") .build(); ProducerTemplate producer = camelctx.createProducerTemplate(); Exchange result = producer.send("direct:start", exchange); String messageId = result.getIn().getHeader(SesConstants.MESSAGE_ID, String.class); Assert.assertNotNull("MessageId not null", messageId); } finally { camelctx.close(); } }