Search in sources :

Example 26 with Consumer

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

the class TimerEndpoint method createConsumer.

public Consumer createConsumer(Processor processor) throws Exception {
    Consumer answer = new TimerConsumer(this, processor);
    configureConsumer(answer);
    return answer;
}
Also used : Consumer(org.apache.camel.Consumer)

Example 27 with Consumer

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

the class SedaEndpoint method createConsumer.

public Consumer createConsumer(Processor processor) throws Exception {
    if (getComponent() != null) {
        // all consumers must match having the same multipleConsumers options
        String key = getComponent().getQueueKey(getEndpointUri());
        QueueReference ref = getComponent().getQueueReference(key);
        if (ref != null && ref.getMultipleConsumers() != isMultipleConsumers()) {
            // there is already a multiple consumers, so make sure they matches
            throw new IllegalArgumentException("Cannot use existing queue " + key + " as the existing queue multiple consumers " + ref.getMultipleConsumers() + " does not match given multiple consumers " + multipleConsumers);
        }
    }
    Consumer answer = createNewConsumer(processor);
    configureConsumer(answer);
    return answer;
}
Also used : PollingConsumer(org.apache.camel.PollingConsumer) Consumer(org.apache.camel.Consumer)

Example 28 with Consumer

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

the class CamelPostProcessorHelper method subscribeMethod.

public void subscribeMethod(Method method, Object bean, String beanName, String endpointUri, String endpointName, String endpointProperty) {
    // lets bind this method to a listener
    String injectionPointName = method.getName();
    Endpoint endpoint = getEndpointInjection(bean, endpointUri, endpointName, endpointProperty, injectionPointName, true);
    if (endpoint != null) {
        try {
            Processor processor = createConsumerProcessor(bean, method, endpoint);
            Consumer consumer = endpoint.createConsumer(processor);
            LOG.debug("Created processor: {} for consumer: {}", processor, consumer);
            startService(consumer, endpoint.getCamelContext(), bean, beanName);
        } catch (Exception e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }
}
Also used : CamelInternalProcessor(org.apache.camel.processor.CamelInternalProcessor) Processor(org.apache.camel.Processor) BeanProcessor(org.apache.camel.component.bean.BeanProcessor) Endpoint(org.apache.camel.Endpoint) PollingConsumer(org.apache.camel.PollingConsumer) Consumer(org.apache.camel.Consumer) NoSuchBeanException(org.apache.camel.NoSuchBeanException) ProxyInstantiationException(org.apache.camel.ProxyInstantiationException)

Example 29 with Consumer

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

the class IgniteMessagingTest method testConsumerManyMessages.

@Test
public void testConsumerManyMessages() throws Exception {
    List<Object> messages = Lists.newArrayList();
    Consumer consumer = context.getEndpoint("ignite:messaging:TOPIC1").createConsumer(storeBodyInListProcessor(messages));
    consumer.start();
    Set<Integer> messagesToSend = ContiguousSet.create(Range.closedOpen(0, 100), DiscreteDomain.integers());
    ignite().message().send(TOPIC1, messagesToSend);
    await().atMost(5, TimeUnit.SECONDS).untilCall(to(messages).size(), equalTo(100));
    consumer.stop();
}
Also used : Consumer(org.apache.camel.Consumer) Test(org.junit.Test)

Example 30 with Consumer

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

the class Jt400Endpoint method createConsumer.

@Override
public Consumer createConsumer(Processor processor) throws Exception {
    if (Jt400Type.DTAQ == configuration.getType()) {
        Consumer consumer = new Jt400DataQueueConsumer(this, processor);
        configureConsumer(consumer);
        return consumer;
    } else {
        throw new OperationNotSupportedException();
    }
}
Also used : OperationNotSupportedException(javax.naming.OperationNotSupportedException) 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