本文整理匯總了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);
}