All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rabbitmq.client.impl.nio.BlockingQueueNioQueue Maven / Gradle / Ivy

Go to download

The RabbitMQ Java client library allows Java applications to interface with RabbitMQ.

There is a newer version: 5.22.0
Show newest version
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 5.5.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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy