Search in sources :

Example 41 with AsyncCallback

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

the class CamelEventHandler method doEventReceived.

/**
     * Callback executed to propagate event from Guava listener to Camel route.
     *
     * @param event the event received by Guava EventBus.
     */
public void doEventReceived(Object event) {
    log.trace("Received event: {}");
    final Exchange exchange = eventBusEndpoint.createExchange(event);
    log.debug("Processing event: {}", event);
    // use async processor to support async routing engine
    processor.process(exchange, new AsyncCallback() {

        @Override
        public void done(boolean doneSync) {
        // noop
        }
    });
}
Also used : Exchange(org.apache.camel.Exchange) AsyncCallback(org.apache.camel.AsyncCallback)

Example 42 with AsyncCallback

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

the class IgniteCacheContinuousQueryConsumer method fireGroupedExchange.

private void fireGroupedExchange(Iterable<CacheEntryEvent<? extends Object, ? extends Object>> events) {
    Exchange exchange = createExchange(events);
    getAsyncProcessor().process(exchange, new AsyncCallback() {

        @Override
        public void done(boolean doneSync) {
        // do nothing
        }
    });
}
Also used : Exchange(org.apache.camel.Exchange) AsyncCallback(org.apache.camel.AsyncCallback)

Example 43 with AsyncCallback

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

the class IgniteCacheContinuousQueryConsumer method fireSingleExchange.

private void fireSingleExchange(CacheEntryEvent<? extends Object, ? extends Object> entry) {
    Exchange exchange = createExchange(entry.getValue());
    exchange.getIn().setHeader(IgniteConstants.IGNITE_CACHE_EVENT_TYPE, entry.getEventType());
    exchange.getIn().setHeader(IgniteConstants.IGNITE_CACHE_OLD_VALUE, entry.getOldValue());
    exchange.getIn().setHeader(IgniteConstants.IGNITE_CACHE_KEY, entry.getKey());
    getAsyncProcessor().process(exchange, new AsyncCallback() {

        @Override
        public void done(boolean doneSync) {
        // do nothing
        }
    });
}
Also used : Exchange(org.apache.camel.Exchange) AsyncCallback(org.apache.camel.AsyncCallback)

Example 44 with AsyncCallback

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

the class IgniteCacheContinuousQueryConsumer method maybeFireExistingQueryResults.

private void maybeFireExistingQueryResults() {
    if (!endpoint.isFireExistingQueryResults()) {
        LOG.info(String.format("Skipping existing cache results for cache name = %s.", endpoint.getCacheName()));
        return;
    }
    LOG.info(String.format("Processing existing cache results for cache name = %s.", endpoint.getCacheName()));
    for (Entry<Object, Object> entry : cursor) {
        Exchange exchange = createExchange(entry.getValue());
        exchange.getIn().setHeader(IgniteConstants.IGNITE_CACHE_KEY, entry.getKey());
        getAsyncProcessor().process(createExchange(entry), new AsyncCallback() {

            @Override
            public void done(boolean doneSync) {
            // do nothing
            }
        });
    }
}
Also used : Exchange(org.apache.camel.Exchange) AsyncCallback(org.apache.camel.AsyncCallback)

Example 45 with AsyncCallback

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

the class CamelJGroupsReceiver method viewAccepted.

@Override
public void viewAccepted(View view) {
    if (endpoint.isEnableViewMessages()) {
        Exchange exchange = endpoint.createExchange(view);
        try {
            LOG.debug("Processing view: {}", view);
            processor.process(exchange, new AsyncCallback() {

                @Override
                public void done(boolean doneSync) {
                // noop
                }
            });
        } catch (Exception e) {
            throw new JGroupsException("Error in consumer while dispatching exchange containing view " + view, e);
        }
    } else {
        LOG.debug("Option enableViewMessages is set to false. Skipping processing of the view: {}", view);
    }
}
Also used : Exchange(org.apache.camel.Exchange) AsyncCallback(org.apache.camel.AsyncCallback)

Aggregations

AsyncCallback (org.apache.camel.AsyncCallback)67 Exchange (org.apache.camel.Exchange)47 AsyncProcessor (org.apache.camel.AsyncProcessor)12 CamelExchangeException (org.apache.camel.CamelExchangeException)8 Message (org.apache.camel.Message)5 Processor (org.apache.camel.Processor)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 Endpoint (org.apache.camel.Endpoint)4 Producer (org.apache.camel.Producer)4 Synchronization (org.apache.camel.spi.Synchronization)4 StopWatch (org.apache.camel.util.StopWatch)4 InetSocketAddress (java.net.InetSocketAddress)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ExchangePattern (org.apache.camel.ExchangePattern)3 ChannelHandler (io.netty.channel.ChannelHandler)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ConnectException (java.net.ConnectException)2