当前位置: 首页>>代码示例>>Java>>正文


Java ExchangeSendingEvent类代码示例

本文整理汇总了Java中org.apache.camel.management.event.ExchangeSendingEvent的典型用法代码示例。如果您正苦于以下问题:Java ExchangeSendingEvent类的具体用法?Java ExchangeSendingEvent怎么用?Java ExchangeSendingEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExchangeSendingEvent类属于org.apache.camel.management.event包,在下文中一共展示了ExchangeSendingEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAsyncEndpointEventNotifier

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
public void testAsyncEndpointEventNotifier() throws Exception {
    getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel");
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");

    String reply = template.requestBody("direct:start", "Hello Camel", String.class);
    assertEquals("Bye Camel", reply);

    assertMockEndpointsSatisfied();

    assertEquals(8, events.size());

    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(0));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(1));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(2));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(3));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(4));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(7));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:AsyncEndpointEventNotifierSendingTest.java

示例2: sendMessageToDefaultCamelContextInbound

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Test
@InSequence(2)
public void sendMessageToDefaultCamelContextInbound(List<Class> events) throws InterruptedException {
    defaultOutbound.expectedMessageCount(1);
    defaultOutbound.expectedBodiesReceived("test-default");
    defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));

    defaultInbound.sendBody("test-default");

    assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:MultiContextEventNotifierTest.java

示例3: sendMessageToFirstCamelContextInbound

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Test
@InSequence(3)
public void sendMessageToFirstCamelContextInbound(@ContextName("first") List<Class> events) throws InterruptedException {
    firstOutbound.expectedMessageCount(1);
    firstOutbound.expectedBodiesReceived("test-first");
    firstOutbound.expectedHeaderReceived("context", "first");
    firstOutbound.message(0).exchange().matches(fromCamelContext("first"));

    firstInbound.sendBody("test-first");

    assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MultiContextEventNotifierTest.java

示例4: sendMessageToSecondCamelContextInbound

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Test
@InSequence(4)
public void sendMessageToSecondCamelContextInbound(@ContextName("second") List<Class> events) throws InterruptedException {
    secondOutbound.expectedMessageCount(1);
    secondOutbound.expectedBodiesReceived("test-second");
    secondOutbound.expectedHeaderReceived("context", "second");
    secondOutbound.message(0).exchange().matches(fromCamelContext("second"));

    secondInbound.sendBody("test-second");

    assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MultiContextEventNotifierTest.java

示例5: sendMessageToInbound

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Test
@InSequence(2)
public void sendMessageToInbound(List<Class> events) throws InterruptedException {
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");

    inbound.sendBody("test");

    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);

    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CamelEventNotifierTest.java

示例6: stopCamelContext

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Test
@InSequence(3)
public void stopCamelContext(CamelContext context, List<Class> events) throws Exception {
    context.stop();

    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class,
            CamelContextStoppingEvent.class,
            CamelContextStoppedEvent.class));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:CamelEventNotifierTest.java

示例7: doNotify

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Override
protected void doNotify(ExchangeSendingEvent event) throws Exception {
    String endpointUri = event.getEndpoint().getEndpointUri();

    if (filter(endpointUri, endpointFilterPattern)) {
        Message msg = event.getExchange().getIn().getHeader(AsynchConstants.MSG_HEADER, Message.class);

        // create request a transforms data to string to store
        String reqBody = transformBody(((Exchange) event.getSource()).getIn());
        String joinId = createResponseJoinId(event.getExchange());

        Request req = Request.createRequest(endpointUri, joinId, reqBody, msg);

        try {
            // save request
            requestResponseService.insertRequest(req);

            // add to exchange for later use when response arrives
            event.getExchange().getIn().setHeader(SAVE_REQ_HEADER, req);
        } catch (Exception ex) {
            Log.error("Request didn't saved.", ex);
        }
    }
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:25,代码来源:RequestSendingEventNotifier.java

示例8: sendMessageToDefaultCamelContextInbound

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Test
@InSequence(2)
public void sendMessageToDefaultCamelContextInbound(@Named("defaultContext") List<Class> events) throws InterruptedException {
    defaultOutbound.expectedMessageCount(1);
    defaultOutbound.expectedBodiesReceived("test-default");
    defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));

    defaultInbound.sendBody("test-default");

    assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:23,代码来源:MultiContextEventNotifierTest.java

示例9: isEnabled

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Override
public boolean isEnabled(EventObject event) {
    return enabled && event instanceof ExchangeCreatedEvent
            || event instanceof ExchangeSendingEvent
            || event instanceof RouteAddedEvent
            || event instanceof RouteRemovedEvent;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:DefaultRuntimeEndpointRegistry.java

示例10: notify

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Override
public void notify(EventObject event) throws Exception {
    if (event instanceof ExchangeSendingEvent) {
        sending++;
    } else {
        sent++;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:RoutingSlipEventNotifierTest.java

示例11: notify

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
@Override
public void notify(EventObject event) throws Exception {
    
    if (event instanceof ExchangeSendingEvent) {
        exchangeSendingEvent.incrementAndGet();
    } else if (event instanceof ExchangeSentEvent) {
        exchangeSentEvent.incrementAndGet();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:EnricherSendEventTest.java

示例12: testExchangeFailed

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
public void testExchangeFailed() throws Exception {
    try {
        template.sendBody("direct:fail", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
    }

    assertEquals(10, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeFailedEvent.class, events.get(8));
    // this is the sent using the produce template to start the test
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));

    context.stop();

    assertEquals(16, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(10));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(11));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(12));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(13));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(14));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(15));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:EventNotifierEventsTest.java

示例13: testExchangeSent

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
public void testExchangeSent() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);

    template.sendBody("direct:start", "Hello World");

    assertMockEndpointsSatisfied();

    assertEquals(8, events.size());
    ExchangeSendingEvent e0 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(0));
    ExchangeSendingEvent e1 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(1));
    ExchangeSentEvent e2 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(2));
    ExchangeSendingEvent e3 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(3));
    ExchangeSentEvent e4 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(4));
    ExchangeSendingEvent e5 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(5));
    ExchangeSentEvent e6 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(6));
    ExchangeSentEvent e7 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(7));

    assertEquals("direct://start", e0.getEndpoint().getEndpointUri());

    assertEquals("log://foo", e1.getEndpoint().getEndpointUri());
    assertEquals("log://foo", e2.getEndpoint().getEndpointUri());

    assertEquals("direct://bar", e3.getEndpoint().getEndpointUri());
    assertEquals("direct://bar", e4.getEndpoint().getEndpointUri());
    long time = e4.getTimeTaken();
    assertTrue("Should take about 0.5 sec, was: " + time, time > 400);

    assertEquals("mock://result", e5.getEndpoint().getEndpointUri());
    assertEquals("mock://result", e6.getEndpoint().getEndpointUri());

    assertEquals("direct://start", e7.getEndpoint().getEndpointUri());
    time = e7.getTimeTaken();
    assertTrue("Should take about 0.5 sec, was: " + time, time > 400);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:EventNotifierExchangeSentTest.java

示例14: testExchangeSentRecipient

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
public void testExchangeSentRecipient() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);

    template.sendBodyAndHeader("direct:foo", "Hello World", "foo", "direct:cool,direct:start");

    assertMockEndpointsSatisfied();

    // give it time to complete
    Thread.sleep(200);

    assertEquals(12, events.size());
    ExchangeSendingEvent e0 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(0));
    ExchangeSendingEvent e1 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(1));
    ExchangeSentEvent e2 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(2));
    ExchangeSendingEvent e3 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(3));
    ExchangeSendingEvent e4 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
    ExchangeSentEvent e5 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(5));
    ExchangeSendingEvent e6 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    ExchangeSentEvent e7 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(7));
    ExchangeSendingEvent e8 = assertIsInstanceOf(ExchangeSendingEvent.class, events.get(8));
    ExchangeSentEvent e9 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));
    ExchangeSentEvent e10 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(10));
    ExchangeSentEvent e11 = assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));

    assertEquals("direct://foo", e0.getEndpoint().getEndpointUri());
    assertEquals("direct://cool", e1.getEndpoint().getEndpointUri());
    assertEquals("direct://cool", e2.getEndpoint().getEndpointUri());
    assertEquals("direct://start", e3.getEndpoint().getEndpointUri());
    assertEquals("log://foo", e4.getEndpoint().getEndpointUri());
    assertEquals("log://foo", e5.getEndpoint().getEndpointUri());
    assertEquals("direct://bar", e6.getEndpoint().getEndpointUri());
    assertEquals("direct://bar", e7.getEndpoint().getEndpointUri());
    assertEquals("mock://result", e8.getEndpoint().getEndpointUri());
    assertEquals("mock://result", e9.getEndpoint().getEndpointUri());
    assertEquals("direct://start", e10.getEndpoint().getEndpointUri());
    assertEquals("direct://foo", e11.getEndpoint().getEndpointUri());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:38,代码来源:EventNotifierExchangeSentTest.java

示例15: testExchangeRedeliverySync

import org.apache.camel.management.event.ExchangeSendingEvent; //导入依赖的package包/类
public void testExchangeRedeliverySync() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(deadLetterChannel("mock:dead").maximumRedeliveries(4).redeliveryDelay(0));

            from("direct:start").throwException(new IllegalArgumentException("Damn"));
        }
    });
    context.start();

    getMockEndpoint("mock:dead").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    assertTrue(oneExchangeDone.matchesMockWaitTime());

    assertEquals(12, events.size());

    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(0));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(1));
    ExchangeRedeliveryEvent e = assertIsInstanceOf(ExchangeRedeliveryEvent.class, events.get(2));
    assertEquals(1, e.getAttempt());
    e = assertIsInstanceOf(ExchangeRedeliveryEvent.class, events.get(3));
    assertEquals(2, e.getAttempt());
    e = assertIsInstanceOf(ExchangeRedeliveryEvent.class, events.get(4));
    assertEquals(3, e.getAttempt());
    e = assertIsInstanceOf(ExchangeRedeliveryEvent.class, events.get(5));
    assertEquals(4, e.getAttempt());
    assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));
    assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
    assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:EventNotifierRedeliveryEventsTest.java


注:本文中的org.apache.camel.management.event.ExchangeSendingEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。