public class QueuedMessageWriter extends Object implements MessageWriter
Note that the writer will continue to accept messages after it has been closed.
| Constructor and Description |
|---|
QueuedMessageWriter(MessageWriter writer)
Create a queued message writer.
|
QueuedMessageWriter(MessageWriter writer,
ExecutorService executor)
Create a queued message writer using the given executor service.
|
QueuedMessageWriter(MessageWriter writer,
ExecutorService executor,
int maxQueueLength)
Create a queued message writer using the given executor service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
separator()
Write an entry separator to the writer.
|
int |
size() |
protected void |
sleep(long ms) |
<Message extends net.morimekta.providence.PMessage<Message>> |
write(net.morimekta.providence.PMessageOrBuilder<Message> message)
Write a providence message to the writer.
|
<Message extends net.morimekta.providence.PMessage<Message>> |
write(net.morimekta.providence.PServiceCall<Message> call)
Write a providence service call to the writer.
|
public QueuedMessageWriter(MessageWriter writer)
writer - The message writer to write to.public QueuedMessageWriter(MessageWriter writer, ExecutorService executor)
writer - The message writer to write to.executor - The executor service running the write loop thread.public QueuedMessageWriter(MessageWriter writer, ExecutorService executor, int maxQueueLength)
writer - The message writer to write to.executor - The executor service running the write loop thread.maxQueueLength - The max queue length. If 0 or less, no limit is enforced.
Default is 65536 (64k).public int size()
public <Message extends net.morimekta.providence.PMessage<Message>> int write(net.morimekta.providence.PMessageOrBuilder<Message> message)
throws IOException
MessageWriterwrite in interface MessageWriterMessage - The message type.message - The message to write.IOException - If write failed.public <Message extends net.morimekta.providence.PMessage<Message>> int write(net.morimekta.providence.PServiceCall<Message> call)
throws IOException
MessageWriterwrite in interface MessageWriterMessage - The message type embedded in the call.call - The service call to write.IOException - If write failed.public int separator()
MessageWriterseparator in interface MessageWriterpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionprotected void sleep(long ms)
throws InterruptedException
InterruptedExceptionCopyright © 2015–2020 morimekta.net. All rights reserved.