當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultCamelContext.getEndpoint方法代碼示例

本文整理匯總了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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:JpaWithNamedQueryAndParametersTest.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:QuartzTwoCamelContextTest.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:QuartzTwoCamelContextTest.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:9,代碼來源:FailoverRoutePolicyTest.java

示例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");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:71,代碼來源:DynamicRoutingExample.java

示例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");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:70,代碼來源:TradeExecutorExample.java


注:本文中的org.apache.camel.impl.DefaultCamelContext.getEndpoint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。