Package io.micronaut.rabbitmq.reactive
Class ReactorReactivePublisher
java.lang.Object
io.micronaut.rabbitmq.reactive.ReactorReactivePublisher
- All Implemented Interfaces:
- ReactivePublisher
@Internal
@EachBean(ChannelPool.class)
public class ReactorReactivePublisher
extends Object
implements ReactivePublisher
A reactive publisher implementation that uses a single channel per publish
 operation and returns a Reactor 
Mono.
 This is an internal API and may change at any time
- Since:
- 3.0.0
- Author:
- James Kleeh, Iván López
- 
Constructor SummaryConstructorsConstructorDescriptionReactorReactivePublisher(ChannelPool channelPool, RabbitConnectionFactoryConfig config) Default constructor.
- 
Method SummaryModifier and TypeMethodDescriptionprotected reactor.core.DisposablecreateConsumer(com.rabbitmq.client.Channel channel, RabbitPublishState publishState, String correlationId, reactor.core.publisher.MonoSink<RabbitConsumerState> emitter) Listens for ack/nack from the broker.protected reactor.core.DisposablecreateListener(com.rabbitmq.client.Channel channel, reactor.core.publisher.MonoSink<Object> emitter, RabbitPublishState publishState) Listens for ack/nack from the broker.protected reactor.core.publisher.Mono<com.rabbitmq.client.Channel>Creates aMonofrom a channel, emitting an error if the channel could not be retrieved.protected reactor.core.publisher.Mono<com.rabbitmq.client.Channel>initializePublish(com.rabbitmq.client.Channel channel) Initializes the channel to allow publisher acknowledgements.reactor.core.publisher.Mono<Void>publish(RabbitPublishState publishState) Publish the message with the provided arguments and return a reactive type that completes successfully when the message is published.reactor.core.publisher.Mono<Void>publishAndConfirm(RabbitPublishState publishState) Publish the message with the provided arguments and return a reactive type that completes successfully when the broker acknowledged the message.reactor.core.publisher.Flux<RabbitConsumerState>publishAndReply(RabbitPublishState publishState) Publish the message with the provided arguments and return a reactive type that completes successfully when the reply is received from the reply to queue.protected reactor.core.publisher.Mono<Object>publishInternal(com.rabbitmq.client.Channel channel, RabbitPublishState publishState) Publishes the message to the channel.protected reactor.core.publisher.Mono<Object>publishInternalNoConfirm(com.rabbitmq.client.Channel channel, RabbitPublishState publishState) Publishes the message to the channel.protected reactor.core.publisher.Mono<RabbitConsumerState>publishRpcInternal(com.rabbitmq.client.Channel channel, RabbitPublishState publishState) Publishes the message to the channel.protected voidreturnChannel(com.rabbitmq.client.Channel channel) Removes confirm listeners from the channel and returns the channel to the pool.
- 
Constructor Details- 
ReactorReactivePublisherpublic ReactorReactivePublisher(@Parameter ChannelPool channelPool, @Parameter RabbitConnectionFactoryConfig config) Default constructor.- Parameters:
- channelPool- The channel pool to retrieve channels
- config- Any configuration used in building the publishers
 
 
- 
- 
Method Details- 
publishAndConfirmDescription copied from interface:ReactivePublisherPublish the message with the provided arguments and return a reactive type that completes successfully when the broker acknowledged the message.- Specified by:
- publishAndConfirmin interface- ReactivePublisher
- Parameters:
- publishState- The RabbitMQ publishing data
- Returns:
- The publisher
 
- 
publishDescription copied from interface:ReactivePublisherPublish the message with the provided arguments and return a reactive type that completes successfully when the message is published.- Specified by:
- publishin interface- ReactivePublisher
- Parameters:
- publishState- The RabbitMQ publishing data
- Returns:
- The publisher
 
- 
publishAndReplypublic reactor.core.publisher.Flux<RabbitConsumerState> publishAndReply(RabbitPublishState publishState) Description copied from interface:ReactivePublisherPublish the message with the provided arguments and return a reactive type that completes successfully when the reply is received from the reply to queue.- Specified by:
- publishAndReplyin interface- ReactivePublisher
- Parameters:
- publishState- The RabbitMQ publishing data
- Returns:
- The publisher of the received reply
 
- 
getChannelprotected reactor.core.publisher.Mono<com.rabbitmq.client.Channel> getChannel()Creates aMonofrom a channel, emitting an error if the channel could not be retrieved.- Returns:
- A Monothat emits the channel on success
 
- 
publishInternalprotected reactor.core.publisher.Mono<Object> publishInternal(com.rabbitmq.client.Channel channel, RabbitPublishState publishState) Publishes the message to the channel. TheMonoreturned from this method should ensure theConfirmListeneris added to the channel prior to publishing and theConfirmListeneris removed from the channel after the publish has been acknowledged.- Parameters:
- channel- The channel to publish the message to
- publishState- The publishing state
- Returns:
- A completable that terminates when the publish has been acknowledged
- See Also:
- 
- Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
 
 
- 
publishRpcInternalprotected reactor.core.publisher.Mono<RabbitConsumerState> publishRpcInternal(com.rabbitmq.client.Channel channel, RabbitPublishState publishState) Publishes the message to the channel. TheMonoreturned from this method should ensure theConfirmListeneris added to the channel prior to publishing and theConfirmListeneris removed from the channel after the publish has been acknowledged.- Parameters:
- channel- The channel to publish the message to
- publishState- The publishing state
- Returns:
- A completable that terminates when the publish has been acknowledged
- See Also:
- 
- Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
 
 
- 
publishInternalNoConfirmprotected reactor.core.publisher.Mono<Object> publishInternalNoConfirm(com.rabbitmq.client.Channel channel, RabbitPublishState publishState) Publishes the message to the channel. TheMonoreturned from this method should ensure theConfirmListeneris added to the channel prior to publishing and theConfirmListeneris removed from the channel after the publish has been acknowledged.- Parameters:
- channel- The channel to publish the message to
- publishState- The publishing state
- Returns:
- A completable that terminates when the publish has been acknowledged
- See Also:
- 
- Channel.basicPublish(String, String, AMQP.BasicProperties, byte[])
 
 
- 
initializePublishprotected reactor.core.publisher.Mono<com.rabbitmq.client.Channel> initializePublish(com.rabbitmq.client.Channel channel) Initializes the channel to allow publisher acknowledgements.- Parameters:
- channel- The channel to enable acknowledgements.
- Returns:
- A Monothat will complete according to the success of the operation.
 
- 
returnChannelprotected void returnChannel(com.rabbitmq.client.Channel channel) Removes confirm listeners from the channel and returns the channel to the pool.- Parameters:
- channel- The channel to clean and return
 
- 
createListenerprotected reactor.core.Disposable createListener(com.rabbitmq.client.Channel channel, reactor.core.publisher.MonoSink<Object> emitter, RabbitPublishState publishState) Listens for ack/nack from the broker. The listener auto disposes itself after receiving a response from the broker. If no response is received, the caller is responsible for disposing the listener.- Parameters:
- channel- The channel to listen for confirms
- emitter- The emitter to send the event
- publishState- The publishing state
- Returns:
- A disposable to allow cleanup of the listener
 
- 
createConsumerprotected reactor.core.Disposable createConsumer(com.rabbitmq.client.Channel channel, RabbitPublishState publishState, String correlationId, reactor.core.publisher.MonoSink<RabbitConsumerState> emitter) throws IOException Listens for ack/nack from the broker. The listener auto disposes itself after receiving a response from the broker. If no response is received, the caller is responsible for disposing the listener.- Parameters:
- channel- The channel to listen for confirms
- publishState- The publish state
- correlationId- The correlation id
- emitter- The emitter to send the response
- Returns:
- A disposable to allow cleanup of the listener
- Throws:
- IOException- If an error occurred subscribing
 
 
-