Search in sources :

Example 6 with SedaEndpoint

use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.

the class AdviceWithMockMultipleEndpointsWithSkipTest method testAdvisedMockEndpointsWithSkip.

// START SNIPPET: e1
// tag::e1[]
public void testAdvisedMockEndpointsWithSkip() throws Exception {
    // advice the first route using the inlined AdviceWith route builder
    // which has extended capabilities than the regular route builder
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {

        @Override
        public void configure() throws Exception {
            // mock sending to direct:foo and direct:bar and skip send to it
            mockEndpointsAndSkip("direct:foo", "direct:bar");
        }
    });
    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
    getMockEndpoint("mock:direct:foo").expectedMessageCount(1);
    getMockEndpoint("mock:direct:bar").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    // the message was not send to the direct:foo route and thus not sent to the seda endpoint
    SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class);
    assertEquals(0, seda.getCurrentQueueSize());
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint) AdviceWithRouteBuilder(org.apache.camel.builder.AdviceWithRouteBuilder)

Example 7 with SedaEndpoint

use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.

the class SpringEndpointPropertyTest method testEndpointProperty.

public void testEndpointProperty() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(2);
    template.sendBody("ref:foo", "Hello World");
    template.sendBody("ref:bar", "Bye World");
    assertMockEndpointsSatisfied();
    SedaEndpoint foo = applicationContext.getBean("foo", SedaEndpoint.class);
    assertNotNull(foo);
    assertEquals(100, foo.getSize());
    assertEquals(5000, foo.getPollTimeout());
    assertEquals(true, foo.isBlockWhenFull());
    assertEquals("seda://foo?blockWhenFull=true&pollTimeout=5000&size=100", foo.getEndpointUri());
    SedaEndpoint bar = applicationContext.getBean("bar", SedaEndpoint.class);
    assertNotNull(bar);
    assertEquals(200, bar.getSize());
    assertEquals("seda://bar?size=200", bar.getEndpointUri());
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint)

Example 8 with SedaEndpoint

use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.

the class DummyRestConsumerFactory method createConsumer.

@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 = ActiveMQUuidGenerator.generateSanitizedId(basePath + uriTemplate);
    } else {
        id = ActiveMQUuidGenerator.generateSanitizedId(basePath);
    }
    // remove leading dash as we add that ourselves
    if (id.startsWith("-")) {
        id = id.substring(1);
    }
    SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
    return seda.createConsumer(processor);
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint)

Example 9 with SedaEndpoint

use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.

the class DummyRestConsumerFactory method createConsumer.

@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 = ActiveMQUuidGenerator.generateSanitizedId(basePath + uriTemplate);
    } else {
        id = ActiveMQUuidGenerator.generateSanitizedId(basePath);
    }
    // remove leading dash as we add that ourselves
    if (id.startsWith("-")) {
        id = id.substring(1);
    }
    SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
    return seda.createConsumer(processor);
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint)

Example 10 with SedaEndpoint

use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.

the class DummyRestConsumerFactory method createConsumer.

@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 = ActiveMQUuidGenerator.generateSanitizedId(basePath + uriTemplate);
    } else {
        id = ActiveMQUuidGenerator.generateSanitizedId(basePath);
    }
    // remove leading dash as we add that ourselves
    if (id.startsWith("-")) {
        id = id.substring(1);
    }
    SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
    return seda.createConsumer(processor);
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint)

Aggregations

SedaEndpoint (org.apache.camel.component.seda.SedaEndpoint)19 Test (org.junit.Test)5 ComponentConfiguration (org.apache.camel.ComponentConfiguration)2 InvalidPropertyException (org.apache.camel.InvalidPropertyException)2 AdviceWithRouteBuilder (org.apache.camel.builder.AdviceWithRouteBuilder)2 SedaComponent (org.apache.camel.component.seda.SedaComponent)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Component (org.apache.camel.Component)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 BlueprintCamelContext (org.apache.camel.blueprint.BlueprintCamelContext)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 DefaultExchange (org.apache.camel.impl.DefaultExchange)1 Ignore (org.junit.Ignore)1