@Beta 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.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
separator()
Write an entry separator to the writer.
|
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 <Message extends PMessage<Message,Field>,Field extends PField> int write(Message message) throws IOException
MessageWriter
write
in interface MessageWriter
Message
- 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
MessageWriter
write
in interface MessageWriter
Message
- 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
MessageWriter
separator
in interface MessageWriter
IOException
- If write failed.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected void sleep(long ms) throws InterruptedException
InterruptedException
Copyright © 2015–2017 morimekta.net. All rights reserved.