com.rabbitmq.client.impl.nio.BlockingQueueNioQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of amqp-client Show documentation
Show all versions of amqp-client Show documentation
The RabbitMQ Java client library allows Java applications to interface with RabbitMQ.
package com.rabbitmq.client.impl.nio;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
/**
* Bridge between {@link NioQueue} and JDK's {@link BlockingQueue}.
*
* @see NioQueue
* @since 4.9.0
*/
public class BlockingQueueNioQueue implements NioQueue {
private final BlockingQueue delegate;
private final int writeEnqueuingTimeoutInMs;
public BlockingQueueNioQueue(BlockingQueue delegate, int writeEnqueuingTimeoutInMs) {
this.delegate = delegate;
this.writeEnqueuingTimeoutInMs = writeEnqueuingTimeoutInMs;
}
@Override
public boolean offer(WriteRequest writeRequest) throws InterruptedException {
return this.delegate.offer(writeRequest, writeEnqueuingTimeoutInMs, TimeUnit.MILLISECONDS);
}
@Override
public int size() {
return this.delegate.size();
}
@Override
public WriteRequest poll() {
return this.delegate.poll();
}
@Override
public boolean isEmpty() {
return this.delegate.isEmpty();
}
}