use of com.lmax.disruptor.BlockingWaitStrategy in project disruptor by LMAX-Exchange.
the class MultiProducerWithTranslator method main.
public static void main(String[] args) throws InterruptedException {
Disruptor<ObjectBox> disruptor = new Disruptor<ObjectBox>(ObjectBox.FACTORY, RING_SIZE, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new BlockingWaitStrategy());
disruptor.handleEventsWith(new Consumer()).then(new Consumer());
final RingBuffer<ObjectBox> ringBuffer = disruptor.getRingBuffer();
Publisher p = new Publisher();
IMessage message = new IMessage();
ITransportable transportable = new ITransportable();
String streamName = "com.lmax.wibble";
System.out.println("publishing " + RING_SIZE + " messages");
for (int i = 0; i < RING_SIZE; i++) {
ringBuffer.publishEvent(p, message, transportable, streamName);
Thread.sleep(10);
}
System.out.println("start disruptor");
disruptor.start();
System.out.println("continue publishing");
while (true) {
ringBuffer.publishEvent(p, message, transportable, streamName);
Thread.sleep(10);
}
}
use of com.lmax.disruptor.BlockingWaitStrategy in project jstorm by alibaba.
the class NettyUnitTest method initNettyServer.
private IConnection initNettyServer(int port) {
ConcurrentHashMap<Integer, DisruptorQueue> deserializeQueues = new ConcurrentHashMap<Integer, DisruptorQueue>();
//ConcurrentHashMap<Integer, DisruptorQueue> deserializeCtrlQueues = new ConcurrentHashMap<Integer, DisruptorQueue>();
WaitStrategy wait = (WaitStrategy) Utils.newInstance("com.lmax.disruptor.TimeoutBlockingWaitStrategy", 5, TimeUnit.MILLISECONDS);
DisruptorQueue recvControlQueue = DisruptorQueue.mkInstance("Dispatch-control", ProducerType.MULTI, 256, wait, false, 0, 0);
Set<Integer> taskSet = new HashSet<Integer>();
taskSet.add(1);
IConnection server = context.bind(null, port, deserializeQueues, recvControlQueue, true, taskSet);
WaitStrategy waitStrategy = new BlockingWaitStrategy();
DisruptorQueue recvQueue = DisruptorQueue.mkInstance("NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy, false, 0, 0);
server.registerQueue(task, recvQueue);
return server;
}
Aggregations