本文整理汇总了Java中org.apache.camel.management.event.ExchangeCompletedEvent类的典型用法代码示例。如果您正苦于以下问题:Java ExchangeCompletedEvent类的具体用法?Java ExchangeCompletedEvent怎么用?Java ExchangeCompletedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExchangeCompletedEvent类属于org.apache.camel.management.event包,在下文中一共展示了ExchangeCompletedEvent类的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: notify
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void notify(EventObject event) throws Exception {
if (event instanceof ExchangeSentEvent) {
ExchangeSentEvent sent = (ExchangeSentEvent) event;
log.info(">>> Took " + sent.getTimeTaken() + " millis to send to external system : " + sent.getEndpoint());
//String endPoint = sent.getEndpoint().getEndpointUri();
}
if (event instanceof ExchangeCompletedEvent) {
ExchangeCompletedEvent exchangeCompletedEvent = (ExchangeCompletedEvent) event;
Exchange exchange = exchangeCompletedEvent.getExchange();
String routeId = exchange.getFromRouteId();
Date created = ((ExchangeCompletedEvent) event).getExchange().getProperty(Exchange.CREATED_TIMESTAMP, Date.class);
// calculate elapsed time
Date now = new Date();
long elapsed = now.getTime() - created.getTime();
log.info(">>> Took " + elapsed + " millis for the exchange on the route : " + routeId);
}
}
开发者ID:nkasvosve,
项目名称:beyondj,
代码行数:19,
代码来源:RouteAuditEventNotifier.java
示例2: notify
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public void notify(EventObject event) throws Exception {
boolean covered = false;
if (event instanceof AbstractExchangeEvent) {
AbstractExchangeEvent ev = AbstractExchangeEvent.class.cast(event);
final Exchange exchange = ev.getExchange();
String metricPrefix = exchange.getFromRouteId();
// if we can't find the prefix for the metrics then don't capture any
if (metricPrefix == null || metricPrefix.equals("")) { return; }
if (ev instanceof ExchangeCompletedEvent || ev instanceof ExchangeFailedEvent || ev instanceof ExchangeRedeliveryEvent) {
onExchangeCompletedEvent(ev, metricPrefix);
covered = true;
} else {
metrics.meter(name(event.getClass(), metricPrefix)).mark();
}
}
if (!covered)
LOGGER.debug("Not covered: Type {} ({})", event.getClass(), event);
}
开发者ID:andrewharmellaw,
项目名称:springboot-camel-metrics-publisher,
代码行数:25,
代码来源:CamelMetricsUpdater.java
示例3: testExchangeCompleted
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void testExchangeCompleted() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
assertEquals(1, events.size());
// get the event
ExchangeCompletedEvent event = (ExchangeCompletedEvent) events.get(0);
assertNotNull(event.getExchange());
assertNotNull(event.getExchange().getFromEndpoint());
assertEquals("direct://start", event.getExchange().getFromEndpoint().getEndpointUri());
// grab the created timestamp
Date created = event.getExchange().getProperty(Exchange.CREATED_TIMESTAMP, Date.class);
assertNotNull(created);
// calculate elapsed time
Date now = new Date();
long elapsed = now.getTime() - created.getTime();
assertTrue("Should be > 400, was: " + elapsed, elapsed > 400);
log.info("Elapsed time in millis: " + elapsed);
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:27,
代码来源:EventNotifierExchangeCompletedTest.java
示例4: sendMessageToDefaultCamelContextInbound
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例5: sendMessageToFirstCamelContextInbound
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例6: sendMessageToSecondCamelContextInbound
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例7: sendMessageToInbound
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例8: stopCamelContext
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例9: notify
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void notify(EventObject event) throws Exception {
if(event instanceof ExchangeCreatedEvent) {
log.debug("RECEIVED CREATE EVENT");
ExchangeCreatedEvent ece = (ExchangeCreatedEvent) event;
Exchange exchange = ece.getExchange();
if(exchange.getProperty(RouteScope.SCOPE_PROPERTY) == null) {
exchange.setProperty(RouteScope.SCOPE_PROPERTY, UUID.randomUUID().toString());
}
ExchangeContextHolder.instance().setContext(new ExchangeAttributes(exchange));
}
if(event instanceof ExchangeCompletedEvent) {
log.debug("RECEIVED COMPLETE EVENT");
ExchangeContextHolder.instance().getContext().executeDesctructionCallbacks();
ExchangeContextHolder.instance().resetContext();
}
}
开发者ID:jyore,
项目名称:spring-scopes,
代码行数:21,
代码来源:ExchangeEventNotifier.java
示例10: sendMessageToDefaultCamelContextInbound
点赞 3
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例11: onEvent
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
// when the exchange is complete, we need to turn off single step mode if we were debug stepping the exchange
if (event instanceof ExchangeCompletedEvent) {
String completedId = ((ExchangeCompletedEvent) event).getExchange().getExchangeId();
if (singleStepExchangeId != null && singleStepExchangeId.equals(completedId)) {
logger.log("ExchangeId: " + completedId + " is completed, so exiting single step mode.");
singleStepExchangeId = null;
}
}
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:13,
代码来源:BacklogDebugger.java
示例12: notify
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public void notify(EventObject event) throws Exception {
AbstractExchangeEvent aee = (AbstractExchangeEvent) event;
Exchange exchange = aee.getExchange();
onEvent(exchange, event);
if (event instanceof ExchangeCompletedEvent) {
// fail safe to ensure we remove single steps when the Exchange is complete
singleSteps.remove(exchange.getExchangeId());
}
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:12,
代码来源:DefaultDebugger.java
示例13: notify
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public void notify(EventObject event) throws Exception {
ExchangeCompletedEvent completedEvent = (ExchangeCompletedEvent) event;
for (Route route : routes) {
throttle(route, completedEvent.getExchange());
}
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:8,
代码来源:ThrottlingInflightRoutePolicy.java
示例14: notify
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void notify(EventObject event) throws Exception {
if (event instanceof ExchangeCreatedEvent) {
onExchangeCreated((ExchangeCreatedEvent) event);
} else if (event instanceof ExchangeCompletedEvent) {
onExchangeCompleted((ExchangeCompletedEvent) event);
} else if (event instanceof ExchangeFailedEvent) {
onExchangeFailed((ExchangeFailedEvent) event);
} else if (event instanceof ExchangeSentEvent) {
onExchangeSent((ExchangeSentEvent) event);
}
// now compute whether we matched
computeMatches();
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:15,
代码来源:NotifyBuilder.java
示例15: setUp
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
breakpoint = new BreakpointSupport() {
public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
String body = exchange.getIn().getBody(String.class);
logs.add("Breakpoint at " + definition + " with body: " + body);
}
public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
String body = exchange.getIn().getBody(String.class);
logs.add("Breakpoint event " + event.getClass().getSimpleName() + " with body: " + body);
}
};
camelCondition = new ConditionSupport() {
public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
return body().contains("Camel").matches(exchange);
}
};
mockCondition = new ConditionSupport() {
public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
// match when sending to mocks
if (definition instanceof ToDefinition) {
ToDefinition to = (ToDefinition) definition;
return to.getUriOrRef().startsWith("mock");
}
return false;
}
};
doneCondition = new ConditionSupport() {
@Override
public boolean matchEvent(Exchange exchange, EventObject event) {
return event instanceof ExchangeCompletedEvent;
}
};
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:41,
代码来源:DebugTest.java
示例16: testExchangeDone
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void testExchangeDone() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
assertEquals(14, 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(ExchangeCreatedEvent.class, events.get(7));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(12));
// this is the sent using the produce template to start the test
assertIsInstanceOf(ExchangeSentEvent.class, events.get(13));
context.stop();
assertEquals(20, events.size());
assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(14));
assertIsInstanceOf(RouteStoppedEvent.class, events.get(15));
assertIsInstanceOf(RouteRemovedEvent.class, events.get(16));
assertIsInstanceOf(RouteStoppedEvent.class, events.get(17));
assertIsInstanceOf(RouteRemovedEvent.class, events.get(18));
assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(19));
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:33,
代码来源:EventNotifierEventsTest.java
示例17: testExchangeRedeliverySync
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的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
示例18: isEnabled
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public boolean isEnabled(EventObject event) {
return event instanceof ExchangeSendingEvent
|| event instanceof ExchangeSentEvent
|| event instanceof ExchangeCreatedEvent
|| event instanceof ExchangeCompletedEvent
|| event instanceof ExchangeFailedEvent;
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:9,
代码来源:ZipkinTracer.java
示例19: matchEvent
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public boolean matchEvent(Exchange exchange, EventObject event) {
return event instanceof ExchangeCompletedEvent;
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:5,
代码来源:BacklogDebugger.java
示例20: isEnabled
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Override
public boolean isEnabled(EventObject event) {
return event instanceof ExchangeCompletedEvent;
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:5,
代码来源:ThrottlingInflightRoutePolicy.java
示例21: onExchangeCompleted
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
private void onExchangeCompleted(ExchangeCompletedEvent event) {
for (EventPredicateHolder predicate : predicates) {
predicate.getPredicate().onExchangeCompleted(event.getExchange());
}
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:6,
代码来源:NotifyBuilder.java
示例22: testExchangeDeadLetterChannel
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void testExchangeDeadLetterChannel() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(deadLetterChannel("mock:dead"));
from("direct:start").throwException(new IllegalArgumentException("Damn"));
}
});
context.start();
getMockEndpoint("mock:dead").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
assertEquals(12, events.size());
assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(5));
ExchangeFailureHandlingEvent e0 = assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
assertEquals("should be DLC", true, e0.isDeadLetterChannel());
assertEquals("mock://dead", e0.getDeadLetterUri());
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));
ExchangeFailureHandledEvent e = assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
assertEquals("should be DLC", true, e.isDeadLetterChannel());
assertTrue("should be marked as failure handled", e.isHandled());
assertFalse("should not be continued", e.isContinued());
SendProcessor send = assertIsInstanceOf(SendProcessor.class, e.getFailureHandler());
assertEquals("mock://dead", send.getDestination().getEndpointUri());
assertEquals("mock://dead", e.getDeadLetterUri());
// dead letter channel will mark the exchange as completed
assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
// and the last event should be the direct:start
assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
ExchangeSentEvent sent = (ExchangeSentEvent) events.get(11);
assertEquals("direct://start", sent.getEndpoint().getEndpointUri());
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:46,
代码来源:EventNotifierFailureHandledEventsTest.java
示例23: testExchangeOnException
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void testExchangeOnException() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(IllegalArgumentException.class).handled(true).to("mock:dead");
from("direct:start").throwException(new IllegalArgumentException("Damn"));
}
});
context.start();
getMockEndpoint("mock:dead").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
assertEquals(12, events.size());
assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(5));
ExchangeFailureHandlingEvent e0 = assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
assertEquals("should NOT be DLC", false, e0.isDeadLetterChannel());
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));
ExchangeFailureHandledEvent e = assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
assertEquals("should NOT be DLC", false, e.isDeadLetterChannel());
assertTrue("should be marked as failure handled", e.isHandled());
assertFalse("should not be continued", e.isContinued());
// onException will handle the exception
assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
// and the last event should be the direct:start
assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
ExchangeSentEvent sent = (ExchangeSentEvent) events.get(11);
assertEquals("direct://start", sent.getEndpoint().getEndpointUri());
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:42,
代码来源:EventNotifierFailureHandledEventsTest.java
示例24: testExchangeDoTryDoCatch
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void testExchangeDoTryDoCatch() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.doTry()
.throwException(new IllegalArgumentException("Damn"))
.doCatch(IllegalArgumentException.class)
.to("mock:dead")
.end();
}
});
context.start();
getMockEndpoint("mock:dead").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
assertEquals(12, events.size());
assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(5));
ExchangeFailureHandlingEvent e0 = assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
assertEquals("should NOT be DLC", false, e0.isDeadLetterChannel());
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));
ExchangeFailureHandledEvent e = assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
assertEquals("should NOT be DLC", false, e.isDeadLetterChannel());
assertFalse("should not be marked as failure handled as it was continued instead", e.isHandled());
assertTrue("should be continued", e.isContinued());
// onException will handle the exception
assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
// and the last event should be the direct:start
assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
ExchangeSentEvent sent = (ExchangeSentEvent) events.get(11);
assertEquals("direct://start", sent.getEndpoint().getEndpointUri());
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:45,
代码来源:EventNotifierFailureHandledEventsTest.java
示例25: testExchangeDone
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public void testExchangeDone() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
assertEquals(14, 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(ExchangeSendingEvent.class, events.get(8));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));
assertIsInstanceOf(ExchangeSendingEvent.class, events.get(10));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(12));
assertIsInstanceOf(ExchangeSentEvent.class, events.get(13));
assertEquals(8, events2.size());
assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(0));
assertIsInstanceOf(ExchangeCreatedEvent.class, events2.get(1));
assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(2));
assertIsInstanceOf(ExchangeSentEvent.class, events2.get(3));
assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(4));
assertIsInstanceOf(ExchangeSentEvent.class, events2.get(5));
assertIsInstanceOf(ExchangeCompletedEvent.class, events2.get(6));
assertIsInstanceOf(ExchangeSentEvent.class, events2.get(7));
context.stop();
assertEquals(20, events.size());
assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(14));
assertIsInstanceOf(RouteStoppedEvent.class, events.get(15));
assertIsInstanceOf(RouteRemovedEvent.class, events.get(16));
assertIsInstanceOf(RouteStoppedEvent.class, events.get(17));
assertIsInstanceOf(RouteRemovedEvent.class, events.get(18));
assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(19));
assertEquals(8, events2.size());
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:46,
代码来源:MultipleEventNotifierEventsTest.java
示例26: camelAllEvents
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
@Test
public void camelAllEvents(@Uri("mock:events") MockEndpoint events) {
assertThat("Events fired are incorrect!", events.getExchanges(),
// We cannot rely on the delivery order of the camel context started event being fired and observed by both CDI event endpoints
either(
contains(
// Started route: route1
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
// Started route: route2
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
// Started CamelContext: camel-cdi
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(CamelContextStartedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
// Started CamelContext: camel-cdi (for CdiEventEndpoint<CamelContextStartedEvent> started)
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class)))
)).or(
contains(
// Started route: route1
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
// Started route: route2
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(RouteStartedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
// Started CamelContext: camel-cdi (for CdiEventEndpoint<CamelContextStartedEvent> started)
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class))),
// Started CamelContext: camel-cdi
hasProperty("in", hasProperty("body", instanceOf(ExchangeCreatedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSendingEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(CamelContextStartedEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeSentEvent.class))),
hasProperty("in", hasProperty("body", instanceOf(ExchangeCompletedEvent.class)))
)
)
);
}
开发者ID:HydAu,
项目名称:Camel,
代码行数:59,
代码来源:CamelEventEndpointTest.java
示例27: isEnabled
点赞 2
import org.apache.camel.management.event.ExchangeCompletedEvent; //导入依赖的package包/类
public boolean isEnabled(EventObject event) {
return (
(event instanceof ExchangeCreatedEvent) ||
(event instanceof ExchangeCompletedEvent)
);
}
开发者ID:jyore,
项目名称:spring-scopes,
代码行数:7,
代码来源:ExchangeEventNotifier.java