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());
}
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;
}
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);
}
}
}
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());
}
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());
}
Aggregations