Example usage for com.rabbitmq.utility BlockingCell uninterruptibleGet

List of usage examples for com.rabbitmq.utility BlockingCell uninterruptibleGet

Introduction

In this page you can find the example usage for com.rabbitmq.utility BlockingCell uninterruptibleGet.

Prototype

public synchronized T uninterruptibleGet(int timeout) throws TimeoutException 

Source Link

Document

As get(long timeout), but catches and ignores InterruptedException, retrying until a value appears or until specified timeout is reached.

Usage

From source file:uk.trainwatch.rabbitmq.RabbitRPCClient.java

License:Apache License

private byte[] primitiveCall(AMQP.BasicProperties props, byte[] message)
        throws IOException, ShutdownSignalException, TimeoutException {
    checkConsumer();/*from w  w w  .j a  v  a2  s. c o m*/
    BlockingCell<Object> k = new BlockingCell<>();

    String replyId = RabbitMQ.newCorrelationId();
    props = ((props == null) ? new AMQP.BasicProperties.Builder() : props.builder()).correlationId(replyId)
            .replyTo(replyQueue).build();
    continuationMap.put(replyId, k);

    publish(props, message);

    Object reply = k.uninterruptibleGet(timeout);
    if (reply instanceof ShutdownSignalException) {
        ShutdownSignalException sig = (ShutdownSignalException) reply;
        ShutdownSignalException wrapper = new ShutdownSignalException(sig.isHardError(),
                sig.isInitiatedByApplication(), sig.getReason(), sig.getReference());
        wrapper.initCause(sig);
        throw wrapper;
    } else {
        return (byte[]) reply;
    }
}