use of org.apache.camel.ProducerTemplate in project Activiti by Activiti.
the class SimpleProcessTest method testRunProcess.
@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"));
}
use of org.apache.camel.ProducerTemplate in project Activiti by Activiti.
the class SimpleSpringProcessTest method testRunProcess.
@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"));
}
use of org.apache.camel.ProducerTemplate in project chuidiang-ejemplos by chuidiang.
the class RouteTest method testRoute.
@Test
public void testRoute() throws Exception {
Thread.sleep(3000);
ProducerTemplate p = context.createProducerTemplate();
p.sendBody("controlbus:route?routeId=myRoute&action=suspend", null);
Thread.sleep(3000);
p.sendBody("controlbus:route?routeId=myRoute&action=resume", null);
System.in.read();
}
use of org.apache.camel.ProducerTemplate in project chuidiang-ejemplos by chuidiang.
the class RouteBinMain method startControlWindow.
private static void startControlWindow(final CamelContext context) {
JFrame frame = new JFrame();
final JCheckBox checkBox = new JCheckBox("Pause");
frame.getContentPane().add(checkBox);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (checkBox.isSelected()) {
ProducerTemplate p = context.createProducerTemplate();
p.sendBody("controlbus:route?routeId=myRoute&action=suspend", null);
} else {
ProducerTemplate p = context.createProducerTemplate();
p.sendBody("controlbus:route?routeId=myRoute&action=resume", null);
}
}
});
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class ProducerTemplateAlreadyExistTest method testShouldBeSingleton.
@Test
public void testShouldBeSingleton() {
ProducerTemplate lookup = context.getRegistry().lookupByNameAndType("myTemplate", ProducerTemplate.class);
assertNotNull("Should lookup producer template", lookup);
ProducerTemplate lookup2 = context.getRegistry().lookupByNameAndType("myTemplate", ProducerTemplate.class);
assertNotNull("Should lookup producer template", lookup);
assertSame("Should be same instances (singleton)", lookup, lookup2);
}
Aggregations