com.rabbitmq.client.ReturnCallback Java Examples

The following examples show how to use com.rabbitmq.client.ReturnCallback. 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: ChannelTest.java    From rabbitmq-mock with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest(name = "publish to {0} should return replyCode {1}")
@CsvSource({
    "boundRoutingKey, -1",
    "unboundRoutingKey, 312",
})
void mandatory_publish_with_direct_exchange(String routingKey, int expectedReplyCode) throws IOException, TimeoutException {
    try (Connection conn = new MockConnectionFactory().newConnection()) {
        try (Channel channel = conn.createChannel()) {
            channel.exchangeDeclare("test", "direct");
            channel.queueDeclare("existingQueue", false, false, false, Collections.emptyMap()).getQueue();
            channel.queueBind("existingQueue", "test", "boundRoutingKey");
            AtomicInteger replyCodeHolder = new AtomicInteger(-1);
            ReturnCallback returnListener = r -> replyCodeHolder.set(r.getReplyCode());
            channel.addReturnListener(returnListener);
            channel.basicPublish("test", routingKey, true, MessageProperties.BASIC, "msg".getBytes());
            assertThat(replyCodeHolder.get()).isEqualTo(expectedReplyCode);
        }
    }
}
 
Example #2
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnListener addReturnListener(ReturnCallback returnCallback) {
    ReturnListener l = new ReturnListenerAdapter(returnCallback);
    returnListeners.add(l);
    return l;
}
 
Example #3
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
private ReturnListenerAdapter(ReturnCallback callback) {
    this.callback = callback;
}
 
Example #4
Source File: PoolableChannel.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public ReturnListener addReturnListener(ReturnCallback returnCallback) {
    return delegate.addReturnListener(returnCallback);
}
 
Example #5
Source File: TestChannel.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ReturnListener addReturnListener(ReturnCallback returnCallback) {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");
}