@Singleton @Internal public class RxJavaReactivePublisher extends Object implements ReactivePublisher<io.reactivex.Completable>
Completable
.
This is an internal API and may change at any timeConstructor and Description |
---|
RxJavaReactivePublisher(ChannelPool channelPool)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected io.reactivex.disposables.Disposable |
createListener(com.rabbitmq.client.Channel channel,
AtomicReference<BrokerResponse> acknowledgement)
Listens for ack/nack from the broker.
|
protected io.reactivex.Single<com.rabbitmq.client.Channel> |
getChannel()
Creates a
Single from a channel, emitting an error
if the channel could not be retrieved. |
protected io.reactivex.Single<com.rabbitmq.client.Channel> |
initializePublish(com.rabbitmq.client.Channel channel)
Initializes the channel to allow publisher acknowledgements.
|
io.reactivex.Completable |
publish(String exchange,
String routingKey,
com.rabbitmq.client.AMQP.BasicProperties properties,
byte[] body)
Publish the message with the provided arguments and return
a reactive type that completes successfully when the broker
acknowledged the message.
|
protected io.reactivex.Completable |
publishInternal(com.rabbitmq.client.Channel channel,
RabbitPublishState publishState)
Publishes the message to the channel.
|
protected void |
returnChannel(com.rabbitmq.client.Channel channel)
Removes confirm listeners from the channel and returns the
channel to the pool.
|
public RxJavaReactivePublisher(ChannelPool channelPool)
channelPool
- The channel pool to retrieve channelspublic io.reactivex.Completable publish(String exchange, String routingKey, com.rabbitmq.client.AMQP.BasicProperties properties, byte[] body)
ReactivePublisher
publish
in interface ReactivePublisher<io.reactivex.Completable>
exchange
- The exchangeroutingKey
- The routing keyproperties
- The propertiesbody
- The bodyprotected io.reactivex.Single<com.rabbitmq.client.Channel> getChannel()
Single
from a channel, emitting an error
if the channel could not be retrieved.Single
that emits the channel on successprotected io.reactivex.Completable publishInternal(com.rabbitmq.client.Channel channel, RabbitPublishState publishState)
Completable
returned from this
method should ensure the ConfirmListener
is added to the channel prior
to publishing and the ConfirmListener
is removed from the channel after
the publish has been acknowledged.channel
- The channel to publish the message topublishState
- The publishing stateChannel.basicPublish(String, String, AMQP.BasicProperties, byte[])
protected io.reactivex.Single<com.rabbitmq.client.Channel> initializePublish(com.rabbitmq.client.Channel channel)
channel
- The channel to enable acknowledgements.Single
that will complete according to the
success of the operation.protected void returnChannel(com.rabbitmq.client.Channel channel)
channel
- The channel to clean and returnprotected io.reactivex.disposables.Disposable createListener(com.rabbitmq.client.Channel channel, AtomicReference<BrokerResponse> acknowledgement)
channel
- The channel to listen for confirmsacknowledgement
- The acknowledgement object to update on response