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 PMessage<Message,Field>,Field extends PField> |
write(Message message)
Write a providence message to the writer.
|
<Message extends PMessage<Message,Field>,Field extends PField> |
write(PServiceCall<Message,Field> 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 PMessage<Message,Field>,Field extends PField> int write(Message message) throws IOException
MessageWriterwrite in interface MessageWriterMessage - The message type.Field - The field type.message - The message to write.IOException - If write failed.public <Message extends PMessage<Message,Field>,Field extends PField> int write(PServiceCall<Message,Field> call) throws IOException
MessageWriterwrite in interface MessageWriterMessage - The message type embedded in the call.Field - The field type embedded in the call.call - The service call to write.IOException - If write failed.public int separator()
throws IOException
MessageWriterseparator in interface MessageWriterIOException - If write failed.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionprotected void sleep(long ms)
throws InterruptedException
InterruptedExceptionCopyright © 2015–2017 morimekta.net. All rights reserved.