org.apache.camel.component.seda.SedaEndpoint Java Examples
The following examples show how to use
org.apache.camel.component.seda.SedaEndpoint.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelRestTest.java From camel-spring-boot with Apache License 2.0 | 6 votes |
@Override public Consumer createApiConsumer( CamelContext camelContext, Processor processor, String contextPath, RestConfiguration configuration, Map<String, Object> parameters) throws Exception { // just use a seda endpoint for testing purpose String id = DefaultUuidGenerator.generateSanitizedId(contextPath); // remove leading dash as we add that ourselves if (id.startsWith("-")) { id = id.substring(1); } SedaEndpoint seda = camelContext.getEndpoint("seda:api:" + "-" + id, SedaEndpoint.class); return seda.createConsumer(processor); }
Example #2
Source File: NotifyTest.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Test public void testNotifyFrom() throws Exception { // use from to indicate it should only be messages originating from the given endpoint NotifyBuilder notify = new NotifyBuilder(context) .from("seda:order").whenDone(1).create(); template.sendBody("seda:quote", "Camel rocks"); template.sendBody("seda:order", "123,2017-04-20'T'15:47:59,4444,5555"); boolean matches = notify.matches(5, TimeUnit.SECONDS); assertTrue(matches); SedaEndpoint confirm = context.getEndpoint("seda:confirm", SedaEndpoint.class); assertEquals(1, confirm.getExchanges().size()); assertEquals("OK,123,2017-04-20'T'15:47:59,4444,5555", confirm.getExchanges().get(0).getIn().getBody()); }
Example #3
Source File: NotifyTest.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Test public void testNotifyWhenAnyDoneMatches() throws Exception { // use a predicate to indicate when a certain message is done NotifyBuilder notify = new NotifyBuilder(context) .from("seda:order").whenAnyDoneMatches(body().isEqualTo("OK,123,2017-04-20'T'15:48:00,2222,3333")).create(); // send in 2 messages. Its the 2nd message we want to test template.sendBody("seda:order", "123,2017-04-20'T'15:47:59,4444,5555"); template.sendBody("seda:order", "123,2017-04-20'T'15:48:00,2222,3333"); boolean matches = notify.matches(5, TimeUnit.SECONDS); assertTrue(matches); SedaEndpoint confirm = context.getEndpoint("seda:confirm", SedaEndpoint.class); // there should be 2 messages on the confirm queue assertEquals(2, confirm.getExchanges().size()); // and the 2nd message should be the message we wanted to test for assertEquals("OK,123,2017-04-20'T'15:48:00,2222,3333", confirm.getExchanges().get(1).getIn().getBody()); }
Example #4
Source File: NotifyTest.java From camelinaction with Apache License 2.0 | 6 votes |
@Test public void testNotifyFrom() throws Exception { // use from to indicate it should only be messages originating from the given endpoint NotifyBuilder notify = new NotifyBuilder(context) .from("seda:order").whenDone(1).create(); template.sendBody("seda:quote", "Camel rocks"); template.sendBody("seda:order", "123,2010-04-20'T'15:47:59,4444,5555"); boolean matches = notify.matches(5, TimeUnit.SECONDS); assertTrue(matches); SedaEndpoint confirm = context.getEndpoint("seda:confirm", SedaEndpoint.class); assertEquals(1, confirm.getExchanges().size()); assertEquals("OK,123,2010-04-20'T'15:47:59,4444,5555", confirm.getExchanges().get(0).getIn().getBody()); }
Example #5
Source File: NotifyTest.java From camelinaction with Apache License 2.0 | 6 votes |
@Test public void testNotifyWhenAnyDoneMatches() throws Exception { // use a predicate to indicate when a certain message is done NotifyBuilder notify = new NotifyBuilder(context) .from("seda:order").whenAnyDoneMatches(body().isEqualTo("OK,123,2010-04-20'T'15:48:00,2222,3333")).create(); // send in 2 messages. Its the 2nd message we want to test template.sendBody("seda:order", "123,2010-04-20'T'15:47:59,4444,5555"); template.sendBody("seda:order", "123,2010-04-20'T'15:48:00,2222,3333"); boolean matches = notify.matches(5, TimeUnit.SECONDS); assertTrue(matches); SedaEndpoint confirm = context.getEndpoint("seda:confirm", SedaEndpoint.class); // there should be 2 messages on the confirm queue assertEquals(2, confirm.getExchanges().size()); // and the 2nd message should be the message we wanted to test for assertEquals("OK,123,2010-04-20'T'15:48:00,2222,3333", confirm.getExchanges().get(1).getIn().getBody()); }
Example #6
Source File: CamelRestTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Override public Consumer createConsumer( CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate, String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters) throws Exception { // just use a seda endpoint for testing purpose String id; if (uriTemplate != null) { id = DefaultUuidGenerator.generateSanitizedId(basePath + uriTemplate); } else { id = DefaultUuidGenerator.generateSanitizedId(basePath); } // remove leading dash as we add that ourselves if (id.startsWith("-")) { id = id.substring(1); } if (configuration.getConsumerProperties() != null) { String ref = (String) configuration.getConsumerProperties().get("dummy"); if (ref != null) { dummy = CamelContextHelper.mandatoryLookup(camelContext, ref.substring(1)); } } SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class); return seda.createConsumer(processor); }