Search in sources :

Example 16 with SedaEndpoint

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

the class MyBlockingQueue method verifyXmlEndpoint.

@Test
@Ignore("@ApplicationScoped bean proxy cannot be casted to endpoint implementation")
public void verifyXmlEndpoint() {
    assertThat("Endpoint type is incorrect!", endpoint, is(instanceOf(SedaEndpoint.class)));
    SedaEndpoint seda = (SedaEndpoint) endpoint;
    assertThat("Endpoint queue is incorrect!", seda.getQueue(), is(instanceOf(MyBlockingQueue.class)));
    assertThat("Endpoint concurrent consumers count is incorrect!", seda.getConcurrentConsumers(), is(equalTo(10)));
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with SedaEndpoint

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

the class ManagedRouteAddFromRouteTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            // put a message pre-early on the seda queue, to trigger the route, which
            // then would add a 2nd route during CamelContext startup. This is a test
            // to ensure the foo route is not started too soon, and thus adding the 2nd
            // route works as expected
            SedaEndpoint seda = context.getEndpoint("seda:start", SedaEndpoint.class);
            seda.getQueue().put(new DefaultExchange(context));
            from("seda:start").routeId("foo").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    RouteBuilder child = new RouteBuilder() {

                        @Override
                        public void configure() throws Exception {
                            from("seda:bar").routeId("bar").to("mock:bar");
                        }
                    };
                    context.addRoutes(child);
                }
            }).to("mock:result");
        }
    };
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint)

Example 18 with SedaEndpoint

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

the class AdviceWithMockEndpointsWithSkipTest method testAdvisedMockEndpointsWithSkip.

// START SNIPPET: 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 skip send to it
            mockEndpointsAndSkip("direct:foo");
        }
    });
    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
    getMockEndpoint("mock:direct:foo").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 19 with SedaEndpoint

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

the class ContextScopedOnExceptionLoadBalancerStopRouteTest method testErrorOkError.

public void testErrorOkError() throws Exception {
    getMockEndpoint("mock:error").expectedBodiesReceived("Kaboom");
    getMockEndpoint("mock:start").expectedBodiesReceived("Kaboom", "World", "Kaboom");
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
    getMockEndpoint("mock:exception").expectedBodiesReceived("Kaboom", "Kaboom");
    template.sendBody("direct:start", "Kaboom");
    template.sendBody("direct:start", "World");
    // give time for route to stop
    Thread.sleep(1000);
    assertEquals(ServiceStatus.Stopped, context.getRouteStatus("errorRoute"));
    template.sendBody("direct:start", "Kaboom");
    assertMockEndpointsSatisfied();
    // should be 1 on the seda queue
    SedaEndpoint seda = getMandatoryEndpoint("seda:error", SedaEndpoint.class);
    SedaEndpoint seda2 = getMandatoryEndpoint("seda:error2", SedaEndpoint.class);
    int size = seda.getQueue().size();
    int size2 = seda2.getQueue().size();
    assertTrue("There should be 1 exchange on the seda or seda2 queue", size == 1 || size2 == 1);
}
Also used : SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint) 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