本文整理汇总了Java中org.apache.camel.ProducerTemplate.send方法的典型用法代码示例。如果您正苦于以下问题:Java ProducerTemplate.send方法的具体用法?Java ProducerTemplate.send怎么用?Java ProducerTemplate.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.ProducerTemplate
的用法示例。
在下文中一共展示了ProducerTemplate.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCamelHeadersFiltered
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@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"));
}
示例2: testCamelHeadersAll
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Deployment(resources = { "org/activiti/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"));
}
示例3: doSignatureRouteTest
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(builder);
context.start();
MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
mock.setExpectedMessageCount(1);
ProducerTemplate template = context.createProducerTemplate();
if (e != null) {
template.send("direct:in", e);
} else {
template.sendBodyAndHeaders("direct:in", payload, headers);
}
assertMockEndpointsSatisfied();
return mock.getReceivedExchanges().get(0);
} finally {
context.stop();
}
}
示例4: testCamelPropertiesNone
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Deployment(resources = { "org/activiti/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"));
}
示例5: testXMLRouteLoading
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
public void testXMLRouteLoading() throws Exception {
applicationContext = createApplicationContext();
SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
assertValidContext(context);
// now lets send a message
ProducerTemplate template = context.createProducerTemplate();
template.start();
template.send("direct:start", new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
in.setHeader("name", "James");
in.setBody(body);
}
});
template.stop();
MyProcessor myProcessor = applicationContext.getBean("myProcessor", MyProcessor.class);
List<Exchange> list = myProcessor.getExchanges();
assertEquals("Should have received a single exchange: " + list, 1, list.size());
}
示例6: testCamelPropertiesAll
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@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"));
}
示例7: testCamelPropertiesAndBody
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Deployment(resources = { "org/flowable/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml" })
public void testCamelPropertiesAndBody() 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"));
assertEquals("sampleBody", variables.get("camelBody"));
}
示例8: testCamelPropertiesFiltered
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Deployment(resources = { "org/flowable/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml" })
public void testCamelPropertiesFiltered() throws Exception {
ProducerTemplate tpl = camelContext.createProducerTemplate();
Exchange exchange = camelContext.getEndpoint("direct:startFilteredProperties").createExchange();
tpl.send("direct:startFilteredProperties", 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"));
}
示例9: testCamelPropertiesNone
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Deployment(resources = { "org/flowable/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"));
}
示例10: testCamelHeadersNone
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@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"));
}
示例11: testCamelHeadersFiltered
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Deployment(resources = { "org/flowable/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"));
}
示例12: sendExchangesThroughDroppingThrottler
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
private void sendExchangesThroughDroppingThrottler(List<Exchange> sentExchanges, int messages) throws Exception {
ProducerTemplate myTemplate = context.createProducerTemplate();
DirectEndpoint targetEndpoint = resolveMandatoryEndpoint("direct:sample", DirectEndpoint.class);
for (int i = 0; i < messages; i++) {
Exchange e = targetEndpoint.createExchange();
e.getIn().setBody("<message>" + i + "</message>");
// only send if we are still started
if (context.getStatus().isStarted()) {
myTemplate.send(targetEndpoint, e);
sentExchanges.add(e);
Thread.sleep(100);
}
}
myTemplate.stop();
}
示例13: testRunProcess
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@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"));
}
示例14: testObjectAsStringVariable
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@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());
}
示例15: testInitiatorCamelCall
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@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);
}