本文整理汇总了Java中org.apache.camel.impl.DefaultCamelContext.createProducerTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultCamelContext.createProducerTemplate方法的具体用法?Java DefaultCamelContext.createProducerTemplate怎么用?Java DefaultCamelContext.createProducerTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.impl.DefaultCamelContext
的用法示例。
在下文中一共展示了DefaultCamelContext.createProducerTemplate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
camelContext = new DefaultCamelContext();
SimpleRegistry registry = new SimpleRegistry();
Map<String, Object> params = new HashMap<String, Object>();
params.put("custName", "Willem");
// bind the params
registry.put("params", params);
camelContext.setRegistry(registry);
template = camelContext.createProducerTemplate();
ServiceHelper.startServices(template, camelContext);
Endpoint value = camelContext.getEndpoint(getEndpointUri());
assertNotNull("Could not find endpoint!", value);
assertTrue("Should be a JPA endpoint but was: " + value, value instanceof JpaEndpoint);
endpoint = (JpaEndpoint)value;
transactionTemplate = endpoint.createTransactionTemplate();
entityManager = endpoint.createEntityManager();
}
示例2: runCafeRouteDemo
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
public void runCafeRouteDemo() throws Exception {
// create CamelContext
DefaultCamelContext camelContext = new DefaultCamelContext();
camelContext.setRegistry(createRegistry());
camelContext.addRoutes(this);
camelContext.start();
ProducerTemplate template = camelContext.createProducerTemplate();
Order order = new Order(2);
order.addItem(DrinkType.ESPRESSO, 2, true);
order.addItem(DrinkType.CAPPUCCINO, 4, false);
order.addItem(DrinkType.LATTE, 4, false);
order.addItem(DrinkType.MOCHA, 2, false);
template.sendBody("direct:cafe", order);
Thread.sleep(6000);
camelContext.stop();
}
示例3: startServices
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void startServices() throws Exception {
deleteDirectory("activemq-data");
camelContext = new DefaultCamelContext();
broker = new JmsBroker("vm://localhost");
broker.start();
// Set up the ActiveMQ JMS Components
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
// Note we can explicitly name the component
camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
camelContext.addRoutes(new LoanBrokerRoute());
template = camelContext.createProducerTemplate();
camelContext.start();
}
示例4: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Override
@Before
protected void setUp() throws Exception {
super.setUp();
context2 = new DefaultCamelContext();
template2 = context2.createProducerTemplate();
ServiceHelper.startServices(template2, context2);
// add routes after CamelContext has been started
RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
if (routeBuilder != null) {
context2.addRoutes(routeBuilder);
}
}
示例5: CamelSink
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
public CamelSink(JsonObject config) {
endpoint = config.getString("endpoint");
camelContext = new DefaultCamelContext();
try {
camelContext.start();
producerTemplate = camelContext.createProducerTemplate();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: shouldNotBreakRedeliveriesOfSecondContextAfterFirstBeingStopped
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Test
public void shouldNotBreakRedeliveriesOfSecondContextAfterFirstBeingStopped() throws Exception {
DefaultCamelContext context1 = createContext();
ProducerTemplate producer1 = context1.createProducerTemplate();
ConsumerTemplate consumer1 = context1.createConsumerTemplate();
context1.start();
producer1.sendBody("seda://input", "Hey1");
Exchange ex1 = consumer1.receive("seda://output", 5000);
DefaultCamelContext context2 = createContext();
ProducerTemplate producer2 = context2.createProducerTemplate();
ConsumerTemplate consumer2 = context2.createConsumerTemplate();
context2.start();
// now stop 1, and see that 2 is still working
consumer1.stop();
producer1.stop();
context1.stop();
producer2.sendBody("seda://input", "Hey2");
Exchange ex2 = consumer2.receive("seda://output", 5000);
Assert.assertNotNull(ex1);
Assert.assertEquals("Hey1", ex1.getIn().getBody());
Assert.assertNotNull(ex2);
Assert.assertEquals("Hey2", ex2.getIn().getBody());
consumer2.stop();
producer2.stop();
context2.stop();
}
示例7: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
public void setUp() throws Exception {
super.setUp();
context.setUseMDCLogging(true);
context2 = new DefaultCamelContext();
context2.setUseMDCLogging(true);
template2 = context2.createProducerTemplate();
ServiceHelper.startServices(template2, context2);
// add routes after CamelContext has been started
context2.addRoutes(createRouteBuilder2());
}
示例8: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Override
@Before
protected void setUp() throws Exception {
super.setUp();
context2 = new DefaultCamelContext();
template2 = context2.createProducerTemplate();
ServiceHelper.startServices(template2, context2);
// add routes after CamelContext has been started
RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
if (routeBuilder != null) {
context2.addRoutes(routeBuilder);
}
}
示例9: ZookeeperPolicyEnforcedContext
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
ZookeeperPolicyEnforcedContext(String name) throws Exception {
controlledContext = new DefaultCamelContext();
routename = name;
template = controlledContext.createProducerTemplate();
mock = controlledContext.getEndpoint("mock:controlled", MockEndpoint.class);
controlledContext.addRoutes(new FailoverRoute(name));
controlledContext.start();
}
示例10: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
TestMessages.getInstance().getMessages().clear();
startTestServer();
camelContext = new DefaultCamelContext();
camelContext.start();
setUpComponent();
template = camelContext.createProducerTemplate();
}
示例11: init
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
camelContext = new DefaultCamelContext();
reactiveCamel = new ReactiveCamel(camelContext);
producerTemplate = camelContext.createProducerTemplate();
camelContext.start();
producerTemplate.start();
}
示例12: setup
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
// you can assign port number in the @CreateTransport annotation
port = super.getLdapServer().getPort();
LdapContext ctx = getWiredContext(ldapServer);
SimpleRegistry reg = new SimpleRegistry();
reg.put("localhost:" + port, ctx);
camel = new DefaultCamelContext(reg);
template = camel.createProducerTemplate();
}
示例13: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
camelContext = new DefaultCamelContext();
camelContext.start();
template = camelContext.createProducerTemplate();
}
示例14: test
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
if (!OS.isFamilyUnix()) {
System.err.println("The test 'CamelExecTest' does not support the following OS : " + System.getProperty("os.name"));
return;
}
String tempFilePath = tempDir.getAbsolutePath() + "/" + tempFileName;
final File script = File.createTempFile("script", ".sh", tempDir);
writeScript(script);
final String exec = "bash?args=" + script.getAbsolutePath() + " " + tempFilePath + "&outFile=" + tempFilePath;
DefaultCamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:source")
.to("file:" + tempDir.getAbsolutePath() + "?fileName=" + tempFileName)
.to("exec:" + exec)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String output = exchange.getIn().getBody(String.class);
assertEquals("hello world\n", output);
}
});
}
});
context.start();
ProducerTemplate pt = context.createProducerTemplate();
String payload = "hello";
pt.sendBody("direct:source", payload);
}