private void poll(Exchange exchange) { exchange.getOut().setBody(this.queue.poll()); }
private static void executeQueue() { System.out.println("### Queue Execution Started... ###"); int key = RANDOM.nextInt(100); IQueue<Integer> queue = (IQueue<Integer>) context.getBean("queue", IQueue.class); queue.add(key); System.out.println("A random integer is added to queue."); System.out.println("Added element: " + queue.poll() + "\n"); }
@Override public Object poll(String queueName, int seconds) { try { return hazelcast.getQueue(queueName).poll(seconds, TimeUnit.SECONDS); } catch (InterruptedException e) { currentThread().interrupt(); return null; } }
public void run() { IQueue queue = hazelcast.getQueue("myQ"); queue.poll(); } }, 10);
@Override public Object poll(String queueName, int seconds) { try { return hazelcast.getQueue(queueName).poll(seconds, TimeUnit.SECONDS); } catch (InterruptedException e) { currentThread().interrupt(); return null; } }
@Override public Object poll(String queueName) { return hazelcast.getQueue(queueName).poll(); }
@Override public Object poll(String queueName) { return hazelcast.getQueue(queueName).poll(); }
protected void handleQPoll(String[] args) { long timeout = 0; if (args.length > 1) { timeout = Long.parseLong(args[1]); } try { println(getQueue().poll(timeout, TimeUnit.SECONDS)); } catch (InterruptedException e) { currentThread().interrupt(); e.printStackTrace(); } }
protected void handleQPoll(String[] args) { long timeout = 0; if (args.length > 1) { timeout = Long.parseLong(args[1]); } try { println(getQueue().poll(timeout, TimeUnit.SECONDS)); } catch (InterruptedException e) { currentThread().interrupt(); e.printStackTrace(); } }
protected void handleQPoll(String[] args) { long timeout = 0; if (args.length > 1) { timeout = Long.parseLong(args[1]); } try { println(getQueue().poll(timeout, TimeUnit.SECONDS)); } catch (InterruptedException e) { currentThread().interrupt(); e.printStackTrace(); } }
protected void handleQPoll(String[] args) { long timeout = 0; if (args.length > 1) { timeout = Long.parseLong(args[1]); } try { println(getQueue().poll(timeout, TimeUnit.SECONDS)); } catch (InterruptedException e) { currentThread().interrupt(); e.printStackTrace(); } }
@Override public void run() { IQueue<String> demoQueue = hazelcastInstance.getQueue("demo.queue"); while (!shutdown) { String data = null; try { data = demoQueue.poll(2, TimeUnit.SECONDS); } catch (InterruptedException ex) { // ignore } if (data != null) { log.info("Read data: {}", data); } } }
e = null; try { e = getQueue().poll(10, TimeUnit.SECONDS); } catch (InterruptedException e1) { LOGGER.warn("CELLAR HAZELCAST: consume task interrupted");
protected void handleQPollMany(String[] args) { int count = 1; if (args.length > 1) { count = Integer.parseInt(args[1]); } int c = 1; for (int i = 0; i < count; i++) { Object obj = getQueue().poll(); if (obj instanceof byte[]) { println(c++ + " " + ((byte[]) obj).length); } else { println(c++ + " " + obj); } } }
protected void handleQPollMany(String[] args) { int count = 1; if (args.length > 1) { count = Integer.parseInt(args[1]); } int c = 1; for (int i = 0; i < count; i++) { Object obj = getQueue().poll(); if (obj instanceof byte[]) { println(c++ + " " + ((byte[]) obj).length); } else { println(c++ + " " + obj); } } }
protected void handleQPollMany(String[] args) { int count = 1; if (args.length > 1) { count = Integer.parseInt(args[1]); } int c = 1; for (int i = 0; i < count; i++) { Object obj = getQueue().poll(); if (obj instanceof byte[]) { println(c++ + " " + ((byte[]) obj).length); } else { println(c++ + " " + obj); } } }
protected void handleQPollMany(String[] args) { int count = 1; if (args.length > 1) { count = Integer.parseInt(args[1]); } int c = 1; for (int i = 0; i < count; i++) { Object obj = getQueue().poll(); if (obj instanceof byte[]) { println(c++ + " " + ((byte[]) obj).length); } else { println(c++ + " " + obj); } } }
queue.add("we have the quorum"); final String value = queue.poll(); System.out.println("Fetched '" + value + "' from the queue");
/** * Read data from the queues. */ @SuppressWarnings("unchecked") @CliCommand(value = "read", help = "Read orders from IQueue and MyPriorityQueue") public void read() throws Exception { // Normal IQueue IQueue<Order> vanilla = this.hazelcastInstance.getQueue("vanilla"); log.info("Queue '{}' has size {}", vanilla.getName(), vanilla.size()); for (int i = 0; !vanilla.isEmpty(); i++) { log.info("Item {} => {}", i, vanilla.poll()); } // MyPriorityQueue DistributedObject distributedObject = this.hazelcastInstance.getDistributedObject(MyPriorityQueue.SERVICE_NAME, "strawberry"); MyPriorityQueue<Order> strawberry = (MyPriorityQueue<Order>) distributedObject; log.info("Queue '{}' has size {}", strawberry.getName(), strawberry.size()); int max = strawberry.size(); for (int i = 0; i < max; i++) { log.info("Item {} => {}", i, strawberry.poll()); } }
@Override public void run() { IQueue<Object> queue = hazelcastInstance.getQueue(cacheName); if (config.getQueueConsumerMode() == HazelcastQueueConsumerMode.LISTEN) { queue.addItemListener(camelItemListener, true); } if (config.getQueueConsumerMode() == HazelcastQueueConsumerMode.POLL) { while (isRunAllowed()) { try { final Object body = queue.poll(config.getPollingTimeout(), TimeUnit.MILLISECONDS); Exchange exchange = getEndpoint().createExchange(); exchange.getOut().setBody(body); try { processor.process(exchange); } catch (Exception e) { getExceptionHandler().handleException("Error during processing", exchange, e); } } catch (InterruptedException e) { if (LOG.isDebugEnabled()) { LOG.debug("Hazelcast Queue Consumer Interrupted: {}", e, e); continue; } } } } } }