com.hazelcast.core.IQueue Java Examples
The following examples show how to use
com.hazelcast.core.IQueue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DemoQueueReader.java From hazelcastmq with Apache License 2.0 | 6 votes |
@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); } } }
Example #2
Source File: HazelcastWorkQueue.java From telekom-workflow-engine with MIT License | 5 votes |
public void awaitEmpty( IQueue<?> queue ) throws InterruptedException{ synchronized( monitor ){ if( !queue.isEmpty() ){ monitor.wait(); } } }
Example #3
Source File: AtomicExample.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 5 votes |
private static void consume(HazelcastInstance hazelcastInstance) { IQueue<String> cola = hazelcastInstance.getQueue("cola"); while (true){ try { System.out.println("Taken from queue: "+cola.take()); } catch (InterruptedException e) { e.printStackTrace(); } } }
Example #4
Source File: AtomicExample.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 5 votes |
private static void produce(HazelcastInstance hazelcastInstance) { IQueue<String> cola = hazelcastInstance.getQueue("cola"); int count=0; while (true){ try { cola.offer(Integer.toString(count++)); Thread.sleep(1000); System.out.println("Added to queue. It has now "+cola.size()); } catch (InterruptedException e) { e.printStackTrace(); } } }
Example #5
Source File: WebConfigurerTest.java From flair-engine with Apache License 2.0 | 4 votes |
@Override public <E> IQueue<E> getQueue(String s) { return null; }
Example #6
Source File: HazelcastWorkQueue.java From telekom-workflow-engine with MIT License | 4 votes |
private IQueue<WorkUnit> getWorkQueue(){ return hcInstance.getQueue( WORK_QUEUE_NAME ); }
Example #7
Source File: HazelcastWorkQueue.java From telekom-workflow-engine with MIT License | 4 votes |
public IsEmptyListener( IQueue<WorkUnit> queue ){ this.queue = queue; }
Example #8
Source File: QueueTopicProxyFactory.java From hazelcastmq with Apache License 2.0 | 3 votes |
/** * Creates an {@link IQueue} proxy around a {@link TransactionalQueue}. This * allows for common handling of queues regardless of if they are * transactional or not. Ideally Hazelcast's transactional queue would * directly implement IQueue but that isn't the case. * * @param <E> the type of objects in the queue * @param queue the transaction queue to create the proxy around * * @return the proxy to the transactional queue */ @SuppressWarnings("unchecked") public static <E> IQueue<E> createQueueProxy(TransactionalQueue<E> queue) { InvocationHandler handler = new TransactionalQueueInvocationHandler<>( queue); return (IQueue<E>) Proxy.newProxyInstance( queue.getClass().getClassLoader(), new Class[]{IQueue.class}, handler); }
Example #9
Source File: QueueTopicProxyFactory.java From hazelcastmq with Apache License 2.0 | 3 votes |
/** * Creates an {@link IQueue} proxy around a standard * {@link ArrayBlockingQueue}. This allows for common handling of queues * regardless of if they are standard Java queues or Hazelcast created queues. * * @param <E> the type of objects in the queue * @param queue the blocking queue to create the proxy around * * @return the proxy to the blocking queue */ @SuppressWarnings("unchecked") public static <E> IQueue<E> createQueueProxy(final ArrayBlockingQueue queue) { InvocationHandler handler = new AbstractQueueInvocationHandler<>(queue); return (IQueue<E>) Proxy.newProxyInstance( IQueue.class.getClassLoader(), new Class[]{IQueue.class}, handler); }