public interface MessageProducer<T> extends WriteStream<T>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WRITE_QUEUE_MAX_SIZE |
Modifier and Type | Method and Description |
---|---|
String |
address() |
void |
close()
Closes the producer, this method should be called when the message producer is not used anymore.
|
void |
close(Handler<AsyncResult<Void>> handler)
Same as
close() but with an handler called when the operation completes |
MessageProducer<T> |
deliveryOptions(DeliveryOptions options)
Update the delivery options of this producer.
|
MessageProducer<T> |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
Closes the producer, calls
close() |
void |
end(Handler<AsyncResult<Void>> handler)
Closes the producer, calls
close(Handler) |
MessageProducer<T> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
MessageProducer<T> |
send(T message)
Deprecated.
instead use
write(T) with a producer obtained from EventBus.sender(java.lang.String) |
<R> MessageProducer<T> |
send(T message,
Handler<AsyncResult<Message<R>>> replyHandler)
Deprecated.
instead use
EventBus.request(String, Object, Handler) |
MessageProducer<T> |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
MessageProducer<T> |
write(T data)
Write some data to the stream.
|
MessageProducer<T> |
write(T data,
Handler<AsyncResult<Void>> handler)
Same as
#write(T) but with an handler called when the operation completes |
end, end, writeQueueFull
static final int DEFAULT_WRITE_QUEUE_MAX_SIZE
@Deprecated MessageProducer<T> send(T message)
write(T)
with a producer obtained from EventBus.sender(java.lang.String)
message
- the message to send@Deprecated <R> MessageProducer<T> send(T message, Handler<AsyncResult<Message<R>>> replyHandler)
EventBus.request(String, Object, Handler)
send(Object)
but specifying a replyHandler
that will be called if the recipient
subsequently replies to the message.message
- the message to sendreplyHandler
- reply handler will be called when any reply from the recipient is received, may be null
MessageProducer<T> exceptionHandler(Handler<Throwable> handler)
WriteStream
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<T>
handler
- the exception handlerMessageProducer<T> write(T data)
WriteStream
WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.write
in interface WriteStream<T>
data
- the data to writeMessageProducer<T> write(T data, Handler<AsyncResult<Void>> handler)
WriteStream
#write(T)
but with an handler
called when the operation completeswrite
in interface WriteStream<T>
MessageProducer<T> setWriteQueueMaxSize(int maxSize)
WriteStream
maxSize
. You will still be able to write to the stream even
if there is more than maxSize
items in the write queue. This is used as an indicator by classes such as
Pump
to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket
, the number of Message
for a
MessageProducer
, etc...setWriteQueueMaxSize
in interface WriteStream<T>
maxSize
- the max size of the write streamMessageProducer<T> drainHandler(Handler<Void> handler)
WriteStream
Pump
for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been
reduced to maxSize / 2
.drainHandler
in interface WriteStream<T>
handler
- the handlerMessageProducer<T> deliveryOptions(DeliveryOptions options)
options
- the new optionsString address()
void end()
close()
end
in interface WriteStream<T>
void end(Handler<AsyncResult<Void>> handler)
close(Handler)
end
in interface WriteStream<T>
void close()
void close(Handler<AsyncResult<Void>> handler)
close()
but with an handler
called when the operation completesCopyright © 2023 Eclipse. All rights reserved.