本文整理汇总了Java中org.apache.camel.impl.DefaultCamelContext.getEndpoint方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultCamelContext.getEndpoint方法的具体用法?Java DefaultCamelContext.getEndpoint怎么用?Java DefaultCamelContext.getEndpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.impl.DefaultCamelContext
的用法示例。
在下文中一共展示了DefaultCamelContext.getEndpoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testThirdCamelContext
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Test
public void testThirdCamelContext() throws Exception {
camel1.stop();
camel2.stop();
DefaultCamelContext camel3 = new DefaultCamelContext();
camel3.setName("camel-3");
camel3.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myThirdGroup/myThirdTimerName?cron=0/1+*+*+*+*+?").to("mock:three");
}
});
camel3.start();
MockEndpoint mock3 = camel3.getEndpoint("mock:three", MockEndpoint.class);
mock3.expectedMinimumMessageCount(2);
mock3.assertIsSatisfied();
camel3.stop();
}
示例3: testThirdCamelContext
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Test
public void testThirdCamelContext() throws Exception {
camel1.stop();
camel2.stop();
DefaultCamelContext camel3 = new DefaultCamelContext();
camel3.setName("camel-3");
camel3.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz://myThirdGroup/myThirdTimerName?cron=0/1+*+*+*+*+?").to("mock:three");
}
});
camel3.start();
MockEndpoint mock3 = camel3.getEndpoint("mock:three", MockEndpoint.class);
mock3.expectedMinimumMessageCount(2);
mock3.assertIsSatisfied();
camel3.stop();
}
示例4: 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();
}
示例5: sendMessage
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
public void sendMessage() throws Exception {
DefaultCamelContext context = new DefaultCamelContext();
final CountDownLatch logonLatch = new CountDownLatch(4);
final CountDownLatch receivedMessageLatch = new CountDownLatch(1);
RouteBuilder routes = new RouteBuilder() {
@Override
public void configure() throws Exception {
// Release latch when session logon events are received
// We expect four logon events (four sessions)
from("quickfix:examples/gateway.cfg").
filter(header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.SessionLogon)).
bean(new CountDownLatchDecrementer("logon", logonLatch));
// Dynamic router -- Uses FIX DeliverTo tags
from("quickfix:examples/gateway.cfg").
filter(header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived)).
recipientList(method(new FixMessageRouter("quickfix:examples/gateway.cfg")));
// Logger app messages as JSON
from("quickfix:examples/gateway.cfg").
filter(PredicateBuilder.or(
header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived),
header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageSent))).
bean(new QuickfixjMessageJsonPrinter());
// If the [email protected] session receives an email then release the latch
from("quickfix:examples/gateway.cfg?sessionID=FIX.4.2:[email protected]>GATEWAY").
filter(PredicateBuilder.and(
header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived),
header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.EMAIL))).
bean(new CountDownLatchDecrementer("message", receivedMessageLatch));
}
};
context.addRoutes(routes);
LOG.info("Starting Camel context");
context.start();
// This is not strictly necessary, but it prevents the need for session
// synchronization due to app messages being sent before being logged on
if (!logonLatch.await(5, TimeUnit.SECONDS)) {
throw new IllegalStateException("Logon did not complete");
}
String gatewayUri = "quickfix:examples/gateway.cfg?sessionID=FIX.4.2:[email protected]>GATEWAY";
Endpoint gatewayEndpoint = context.getEndpoint(gatewayUri);
Producer producer = gatewayEndpoint.createProducer();
Email email = TestSupport.createEmailMessage("Dynamic Routing Example");
email.getHeader().setString(DeliverToCompID.FIELD, "[email protected]");
LOG.info("Sending routed message");
Exchange exchange = producer.createExchange(ExchangePattern.InOnly);
exchange.getIn().setBody(email);
producer.process(exchange);
if (!receivedMessageLatch.await(5, TimeUnit.SECONDS)) {
throw new IllegalStateException("Message did not reach target");
}
LOG.info("Message received, shutting down Camel context");
context.stop();
LOG.info("Dynamic routing example complete");
}
示例6: sendMessage
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
public void sendMessage() throws Exception {
DefaultCamelContext context = new DefaultCamelContext();
context.addComponent("trade-executor", new TradeExecutorComponent());
final CountDownLatch logonLatch = new CountDownLatch(2);
final CountDownLatch executionReportLatch = new CountDownLatch(2);
RouteBuilder routes = new RouteBuilder() {
@Override
public void configure() throws Exception {
// Release latch when session logon events are received
from("quickfix:examples/inprocess.cfg").
filter(header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.SessionLogon)).
bean(new CountDownLatchDecrementer("logon", logonLatch));
from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:MARKET->TRADER").
filter(header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived)).
to("trade-executor:market");
from("trade-executor:market").to("quickfix:examples/inprocess.cfg");
// Logger app messages as JSON
from("quickfix:examples/inprocess.cfg").
filter(PredicateBuilder.or(
header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived),
header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageSent))).
bean(new QuickfixjMessageJsonPrinter());
// Release latch when trader receives execution report
from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:TRADER->MARKET").
filter(PredicateBuilder.and(
header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AppMessageReceived),
header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.EXECUTION_REPORT))).
bean(new CountDownLatchDecrementer("execution report", executionReportLatch));
}
};
context.addRoutes(routes);
LOG.info("Starting Camel context");
context.start();
// This is not strictly necessary, but it prevents the need for session
// synchronization due to app messages being sent before being logged on
if (!logonLatch.await(5, TimeUnit.SECONDS)) {
throw new IllegalStateException("Logon did not complete");
}
String gatewayUri = "quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:TRADER->MARKET";
Endpoint gatewayEndpoint = context.getEndpoint(gatewayUri);
Producer producer = gatewayEndpoint.createProducer();
LOG.info("Sending order");
NewOrderSingle order = createNewOrderMessage();
Exchange exchange = producer.createExchange(ExchangePattern.InOnly);
exchange.getIn().setBody(order);
producer.process(exchange);
if (!executionReportLatch.await(5, TimeUnit.SECONDS)) {
throw new IllegalStateException("Did not receive execution reports");
}
LOG.info("Message received, shutting down Camel context");
context.stop();
LOG.info("Order execution example complete");
}