Search in sources :

Example 71 with Consumer

use of org.apache.camel.Consumer in project camel by apache.

the class AtmosConsumerTest method shouldCreateGetConsumer.

@Test
public void shouldCreateGetConsumer() throws Exception {
    // Given
    AtmosEndpoint atmosEndpoint = context.getEndpoint("atmos:foo/get?remotePath=/path", AtmosEndpoint.class);
    // When
    Consumer consumer = atmosEndpoint.createConsumer(null);
    // Then
    Assert.assertTrue(consumer instanceof AtmosScheduledPollGetConsumer);
    assertEquals("foo", atmosEndpoint.getConfiguration().getName());
}
Also used : AtmosScheduledPollGetConsumer(org.apache.camel.component.atmos.integration.consumer.AtmosScheduledPollGetConsumer) Consumer(org.apache.camel.Consumer) AtmosScheduledPollGetConsumer(org.apache.camel.component.atmos.integration.consumer.AtmosScheduledPollGetConsumer) Test(org.junit.Test)

Example 72 with Consumer

use of org.apache.camel.Consumer in project camel by apache.

the class DefaultRouteStartupOrder method getInputs.

public List<Consumer> getInputs() {
    List<Consumer> answer = new ArrayList<Consumer>();
    Map<Route, Consumer> inputs = routeService.getInputs();
    for (Consumer consumer : inputs.values()) {
        answer.add(consumer);
    }
    return answer;
}
Also used : Consumer(org.apache.camel.Consumer) ArrayList(java.util.ArrayList) Route(org.apache.camel.Route)

Example 73 with Consumer

use of org.apache.camel.Consumer in project camel by apache.

the class DefaultShutdownStrategy method shutdownRoutesNow.

/**
     * Shutdown all the consumers immediately.
     *
     * @param routes the routes to shutdown
     */
protected void shutdownRoutesNow(List<RouteStartupOrder> routes) {
    for (RouteStartupOrder order : routes) {
        // set the route to shutdown as fast as possible by stopping after
        // it has completed its current task
        ShutdownRunningTask current = order.getRoute().getRouteContext().getShutdownRunningTask();
        if (current != ShutdownRunningTask.CompleteCurrentTaskOnly) {
            LOG.debug("Changing shutdownRunningTask from {} to " + ShutdownRunningTask.CompleteCurrentTaskOnly + " on route {} to shutdown faster", current, order.getRoute().getId());
            order.getRoute().getRouteContext().setShutdownRunningTask(ShutdownRunningTask.CompleteCurrentTaskOnly);
        }
        for (Consumer consumer : order.getInputs()) {
            shutdownNow(consumer);
        }
    }
}
Also used : ShutdownRunningTask(org.apache.camel.ShutdownRunningTask) Consumer(org.apache.camel.Consumer) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder)

Example 74 with Consumer

use of org.apache.camel.Consumer in project camel by apache.

the class SedaEndpointTest method testSedaConsumer.

public void testSedaConsumer() throws Exception {
    SedaEndpoint seda = context.getEndpoint("seda://foo", SedaEndpoint.class);
    Consumer consumer = seda.createConsumer(new Processor() {

        public void process(Exchange exchange) throws Exception {
        // do nothing
        }
    });
    assertSame(seda, consumer.getEndpoint());
    assertNotNull(consumer.toString());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Consumer(org.apache.camel.Consumer)

Example 75 with Consumer

use of org.apache.camel.Consumer in project camel by apache.

the class SedaEndpointTest method testSedaEndpointTwo.

public void testSedaEndpointTwo() throws Exception {
    SedaEndpoint seda = new SedaEndpoint("seda://foo", context.getComponent("seda"), queue, 2);
    assertNotNull(seda);
    assertEquals(1000, seda.getSize());
    assertSame(queue, seda.getQueue());
    assertEquals(2, seda.getConcurrentConsumers());
    Producer prod = seda.createProducer();
    seda.onStarted((SedaProducer) prod);
    assertEquals(1, seda.getProducers().size());
    Consumer cons = seda.createConsumer(new Processor() {

        public void process(Exchange exchange) throws Exception {
        // do nothing
        }
    });
    seda.onStarted((SedaConsumer) cons);
    assertEquals(1, seda.getConsumers().size());
    assertEquals(0, seda.getExchanges().size());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Producer(org.apache.camel.Producer) Consumer(org.apache.camel.Consumer)

Aggregations

Consumer (org.apache.camel.Consumer)76 Endpoint (org.apache.camel.Endpoint)27 Processor (org.apache.camel.Processor)19 Exchange (org.apache.camel.Exchange)18 Test (org.junit.Test)18 HashMap (java.util.HashMap)10 RestConfiguration (org.apache.camel.spi.RestConfiguration)10 Producer (org.apache.camel.Producer)7 PollingConsumer (org.apache.camel.PollingConsumer)6 File (java.io.File)5 PollingConsumerPollStrategy (org.apache.camel.spi.PollingConsumerPollStrategy)5 FileNotFoundException (java.io.FileNotFoundException)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 SuspendableService (org.apache.camel.SuspendableService)4 ArrayList (java.util.ArrayList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 CamelContext (org.apache.camel.CamelContext)3 Component (org.apache.camel.Component)3 NoSuchBeanException (org.apache.camel.NoSuchBeanException)3 Route (org.apache.camel.Route)3