private void put(Exchange exchange) throws InterruptedException { Object body = exchange.getIn().getBody(); this.queue.put(body); }
public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IQueue<Integer> queue = hz.getQueue("queue"); for (int i = 1; i < 1000; i++) { queue.put(200 + i); System.out.println("Producing: " + i); Thread.sleep(1000); } queue.put(-1); System.out.println("Producer Finished"); } }
public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IQueue<Integer> queue = hz.getQueue("queue"); for (int i = 1; i < 100; i++) { queue.put(i); System.out.println("Producing: " + i); Thread.sleep(1000); } queue.put(-1); System.out.println("Producer Finished!"); } }
/** * Queue a decoded event. * * @param decoded * @throws SiteWhereException */ protected void queueEvent(DecodedDeviceRequest<?> decoded) throws SiteWhereException { try { getEventQueue().put(decoded); } catch (InterruptedException e) { LOGGER.warn("Interrupted while putting event on queue.", e); } }
public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IQueue<Integer> queue = hz.getQueue("queue"); while (true) { int item = queue.take(); System.out.println("Consumed: " + item); if (item == -1) { queue.put(-1); break; } Thread.sleep(5000); } System.out.println("Consumer Finished!"); } }
public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IQueue<Integer> queue = hz.getQueue("queue"); while (true) { int item = queue.take(); System.out.println("Consumed: " + item); if (item == -1) { queue.put(-1); break; } Thread.sleep(5000); } System.out.println("Consumer Finished!"); } }
public static void main(String[] args) throws InterruptedException { ClientConfig clientConfig = new XmlClientConfigBuilder().build(); final HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); System.out.println(clientConfig.toString()); IQueue<String> queue = client.getQueue("queue"); queue.put("Hello!"); System.out.println("Message sent by Hazelcast Client!"); HazelcastClient.shutdownAll(); } }
@Override public void run() { try { long iteration = 0; while (!testContext.isStopped()) { long item = fromQueue.take(); toQueue.put(item + 1); if (iteration % 200 == 0) { log.info(Thread.currentThread().getName() + " At iteration: " + iteration+" fromQueue size="+fromQueue.size()+", toQueue size="+toQueue.size()); } iteration++; } toQueue.put(0L); totalCounter.addAndGet(iteration); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
public static void main(String[] args) throws Exception { QueueStoreConfig storeConfig = new QueueStoreConfig().setClassName(TheQueueStore.class.getName()); QueueConfig queueConfig = new QueueConfig().setName("queue"); queueConfig.setQueueStoreConfig(storeConfig); Config config = new Config().addQueueConfig(queueConfig); HazelcastInstance hz = Hazelcast.newHazelcastInstance(config); IQueue<Item> queue = hz.getQueue("queue"); queue.put(new Item()); System.exit(0); } }
Order order = orders.get(i); log.info("Item {} => {}", i, order); vanilla.put(order);
@Override public void produce(E event) { if (this.getSwitch().getStatus().equals(SwitchStatus.ON) || event.getForce() || event instanceof Result) { if (event instanceof Result || event instanceof Command) event.setSourceNode(node); try { queue.put(event); } catch (InterruptedException e) { LOGGER.error("CELLAR HAZELCAST: queue producer interrupted", e); } } else { if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) { LOGGER.debug("CELLAR HAZELCAST: {} switch is OFF, don't produce the cluster event", SWITCH_ID); } } }
@Override public void produce(E event) { if (this.getSwitch().getStatus().equals(SwitchStatus.ON) || event.getForce() || event instanceof Result) { if (event instanceof Result || event instanceof Command) event.setSourceNode(node); try { queue.put(event); } catch (InterruptedException e) { LOGGER.error("CELLAR HAZELCAST: queue producer interrupted", e); } } else { if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) { LOGGER.debug("CELLAR HAZELCAST: {} switch is OFF, don't produce the cluster event", SWITCH_ID); } } }