public class MessageProducerImpl<T> extends Object implements MessageProducer<T>
| Modifier and Type | Field and Description |
|---|---|
static String |
CREDIT_ADDRESS_HEADER_NAME |
DEFAULT_WRITE_QUEUE_MAX_SIZE| Constructor and Description |
|---|
MessageProducerImpl(Vertx vertx,
String address,
boolean send,
DeliveryOptions options) |
| 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
MessageProducer.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
MessageProducer.close() |
void |
end(Handler<AsyncResult<Void>> handler)
Closes the producer, calls
MessageProducer.close(Handler) |
MessageProducer<T> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
protected void |
finalize() |
MessageProducer<T> |
send(T message)
This method actually sends a message using the send semantic regardless this producer
is a sender or a publisher.
|
<R> MessageProducer<T> |
send(T message,
Handler<AsyncResult<Message<R>>> replyHandler)
Like
MessageProducer.send(Object) but specifying a replyHandler that will be called if the recipient
subsequently replies to the message. |
MessageProducer<T> |
setWriteQueueMaxSize(int s)
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 |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitend, endpublic static final String CREDIT_ADDRESS_HEADER_NAME
public MessageProducerImpl(Vertx vertx, String address, boolean send, DeliveryOptions options)
public MessageProducer<T> deliveryOptions(DeliveryOptions options)
MessageProducerdeliveryOptions in interface MessageProducer<T>options - the new optionspublic MessageProducer<T> send(T message)
MessageProducersend in interface MessageProducer<T>message - the message to sendpublic <R> MessageProducer<T> send(T message, Handler<AsyncResult<Message<R>>> replyHandler)
MessageProducerMessageProducer.send(Object) but specifying a replyHandler that will be called if the recipient
subsequently replies to the message.send in interface MessageProducer<T>message - the message to sendreplyHandler - reply handler will be called when any reply from the recipient is received, may be nullpublic MessageProducer<T> exceptionHandler(Handler<Throwable> handler)
WriteStreamexceptionHandler in interface MessageProducer<T>exceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<T>handler - the exception handlerpublic MessageProducer<T> setWriteQueueMaxSize(int s)
WriteStreammaxSize. 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 MessageProducer<T>setWriteQueueMaxSize in interface WriteStream<T>s - the max size of the write streampublic MessageProducer<T> write(T data)
WriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.write in interface MessageProducer<T>write in interface WriteStream<T>data - the data to writepublic MessageProducer<T> write(T data, Handler<AsyncResult<Void>> handler)
WriteStream#write(T) but with an handler called when the operation completeswrite in interface MessageProducer<T>write in interface WriteStream<T>public boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)writeQueueFull in interface WriteStream<T>public MessageProducer<T> drainHandler(Handler<Void> handler)
WriteStreamPump 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 MessageProducer<T>drainHandler in interface WriteStream<T>handler - the handlerpublic String address()
address in interface MessageProducer<T>public void end()
MessageProducerMessageProducer.close()end in interface MessageProducer<T>end in interface WriteStream<T>public void end(Handler<AsyncResult<Void>> handler)
MessageProducerMessageProducer.close(Handler)end in interface MessageProducer<T>end in interface WriteStream<T>public void close()
MessageProducerclose in interface MessageProducer<T>public void close(Handler<AsyncResult<Void>> handler)
MessageProducerMessageProducer.close() but with an handler called when the operation completesclose in interface MessageProducer<T>Copyright © 2020. All rights reserved.