reactor / reactor-rabbitmq

Reactor RabbitMQ
Apache License 2.0
157 stars 55 forks source link

Blocking call when "Sender::sendWithPublisherConfirms" #153

Closed 62mkv closed 3 years ago

62mkv commented 3 years ago

BlockHound throws a Blocking call! exception when publisher, created with Sender::sendWithPublisherConfirms is requested

Expected Behavior

I would expect (although it might be wrong expectation) that reactor-rabbimq would not use blocking operations.

Actual Behavior

Exception is thrown by BlockHound when tests are executed; with the following stack trace:

Stack trace:
        at java.net.SocketOutputStream.socketWrite0(SocketOutputStream.java)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
        at java.io.BufferedOutputStream.write(BufferedOutputStream.java:121)
        at java.io.DataOutputStream.write(DataOutputStream.java:107)
        at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:167)
        at com.rabbitmq.client.impl.Frame.writeTo(Frame.java:189)
        at com.rabbitmq.client.impl.SocketFrameHandler.writeFrame(SocketFrameHandler.java:191)
        at com.rabbitmq.client.impl.AMQConnection.writeFrame(AMQConnection.java:627)
        at com.rabbitmq.client.impl.AMQCommand.transmit(AMQCommand.java:127)
        at com.rabbitmq.client.impl.AMQChannel.quiescingTransmit(AMQChannel.java:455)
        at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:428)
        at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:710)
        at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:685)
        at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:202)
        at reactor.rabbitmq.Sender$PublishConfirmSubscriber.onNext(Sender.java:997)
        at reactor.rabbitmq.Sender$PublishConfirmSubscriber.onNext(Sender.java:857)
        at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2317)
        at reactor.rabbitmq.Sender$PublishConfirmSubscriber.request(Sender.java:898)
...

Steps to Reproduce

This is the production code that causes the issue:


        return sender.sendWithPublishConfirms(
                Mono.just(
                        new OutboundMessage(
                                exchangeName,
                                ROUTING_KEY,
                                properties,
                                message.getBytes()
                        )
                ), sendOptions
        )```

## Possible Solution
<!--- Not obligatory, but you can suggest a fix/reason for the bug. -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in. -->
<!--- Especially, always include the version(s) of Reactor library/libraries you used! -->

* Reactor RabbitMQ version(s) used: 1.5.1
* Reactor Core version used: 3.3.5.RELEASE
* Other relevant libraries versions (eg. `netty`, ...): 4.1.49.Final
* JVM version (`java -version`): 1.8.0_172
* OS and version (eg `uname -a`): Win10 x64
acogoluegnes commented 3 years ago

Make sure to configure the connection factory to use NIO:

ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.useNio();

SenderOptions senderOptions =  new SenderOptions()
    .connectionFactory(connectionFactory);

Resources:

62mkv commented 3 years ago

I see.. well, as discussed in #145 , we can not (for whichever reason) use NIO, so I'll close this one. thanks for your support @acogoluegnes !