Package org.apache.camel.component.seda

Examples of org.apache.camel.component.seda.SedaEndpoint


        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());
    }
View Full Code Here


            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 {
View Full Code Here

        }
        // 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);
    }
View Full Code Here

        template.sendBody("direct:start", "B");
        template.sendBody("direct:start", "C");
        template.sendBody("direct:start", "D");
        template.sendBody("direct:start", "E");

        SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class);
        assertEquals(5, seda.getCurrentQueueSize());

        String body = consumer.receiveBody(seda, 1000, String.class);
        assertEquals("A", body);
        assertEquals(4, seda.getCurrentQueueSize());

        body = consumer.receiveBody(seda, 1000, String.class);
        assertEquals("B", body);
        assertEquals(3, seda.getCurrentQueueSize());

        body = consumer.receiveBody(seda, 1000, String.class);
        assertEquals("C", body);
        assertEquals(2, seda.getCurrentQueueSize());

        body = consumer.receiveBody(seda, 1000, String.class);
        assertEquals("D", body);
        assertEquals(1, seda.getCurrentQueueSize());

        body = consumer.receiveBody(seda, 1000, String.class);
        assertEquals("E", body);
        assertEquals(0, seda.getCurrentQueueSize());
    }
View Full Code Here

        }
        // 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);
    }
View Full Code Here

        }
        // 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);
    }
View Full Code Here

        endpointSizeQueue.clear();
        final Runnable monitoring = new Runnable() {
            @Override
            public void run() {
                if (endpoint instanceof SedaEndpoint) {
                    final SedaEndpoint sedaEndpoint = (SedaEndpoint)endpoint;
                    endpointSizeQueue.offer(sedaEndpoint.getCurrentQueueSize());
                } else if (endpoint instanceof DisruptorEndpoint) {
                    final DisruptorEndpoint disruptorEndpoint = (DisruptorEndpoint)endpoint;

                    long remainingCapacity = 0;
                    try {
View Full Code Here

            fail("Should have got InvalidPropertyException thrown!");
        } catch (InvalidPropertyException e) {
            LOG.info("Got expected exception: " + e);
        }

        SedaEndpoint endpoint = TestSupport
                .assertIsInstanceOf(SedaEndpoint.class, configuration.createEndpoint());
        assertEquals("concurrentConsumers", 5, endpoint.getConcurrentConsumers());
        assertEquals("size", 1000, endpoint.getSize());

        assertEquals("endpoint uri", "foo?concurrentConsumers=5&size=1000", endpoint.getEndpointUri());

        // lets try configure a parameter
        configuration.setEndpointParameter(endpoint, "concurrentConsumers", 6);
        assertEquals("concurrentConsumers", 6, endpoint.getConcurrentConsumers());

        // lets try set an invalid parameter
        try {
            configuration.setEndpointParameter(endpoint, "doesNotExist", 1000);
            fail("Should have got InvalidPropertyException thrown!");
View Full Code Here

     * Shows how we can use the configuration to get and set parameters directly on the endpoint
     * for a {@link UriEndpointComponent}
     */
    @Test
    public void testConfigureAnExistingSedaEndpoint() throws Exception {
        SedaEndpoint endpoint = context.getEndpoint("seda:cheese?concurrentConsumers=5", SedaEndpoint.class);
        SedaComponent component = endpoint.getComponent();
        ComponentConfiguration configuration = component.createComponentConfiguration();

        assertEquals("concurrentConsumers", 5, endpoint.getConcurrentConsumers());
        assertEquals("concurrentConsumers", 5,
                configuration.getEndpointParameter(endpoint, "concurrentConsumers"));

        // lets try set and get some valid parameters
        configuration.setEndpointParameter(endpoint, "concurrentConsumers", 10);
View Full Code Here

    private static final AtomicInteger START_COUNTER = new AtomicInteger();

    @Override
    protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
        BlockingQueue<Exchange> blockingQueue = getBlockingQueue(uri, parameters);
        return new SedaEndpoint(uri, this, blockingQueue);
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.component.seda.SedaEndpoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.