Search in sources :

Example 1 with ContinuousQuery

use of org.infinispan.query.api.continuous.ContinuousQuery in project camel by apache.

the class InfinispanConsumer method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    manager.start();
    cache = manager.getCache();
    if (configuration.hasQueryBuilder()) {
        if (InfinispanUtil.isRemote(cache)) {
            RemoteCache<Object, Object> remoteCache = InfinispanUtil.asRemote(cache);
            Query query = InfinispanRemoteOperation.buildQuery(configuration.getQueryBuilder(), remoteCache);
            continuousQuery = Search.getContinuousQuery(remoteCache);
            continuousQuery.addContinuousQueryListener(query, new ContinuousQueryEventListener(cache.getName()));
        } else {
            throw new IllegalArgumentException("Can't run continuous queries against embedded cache (" + cache.getName() + ")");
        }
    } else {
        if (manager.isCacheContainerEmbedded()) {
            consumerHandler = InfinispanConsumerEmbeddedHandler.INSTANCE;
        } else if (manager.isCacheContainerRemote()) {
            consumerHandler = InfinispanConsumerRemoteHandler.INSTANCE;
        } else {
            throw new UnsupportedOperationException("Unsupported CacheContainer type " + manager.getCacheContainer().getClass().getName());
        }
        listener = consumerHandler.start(this);
    }
}
Also used : ContinuousQuery(org.infinispan.query.api.continuous.ContinuousQuery) Query(org.infinispan.query.dsl.Query)

Aggregations

ContinuousQuery (org.infinispan.query.api.continuous.ContinuousQuery)1 Query (org.infinispan.query.dsl.Query)1