public interface MarshallableOut extends DocumentWritten, RollbackIfNotCompleteNotifier
Use the builder(URL) method to create an instance of MarshallableOutBuilder to help construct
appropriate implementations based on provided URLs.
| Modifier and Type | Method and Description |
|---|---|
DocumentContext |
acquireWritingDocument(boolean metaData)
Start or reuse an existing a DocumentContext, optionally call close() when done.
|
static MarshallableOutBuilder |
builder(URL url)
Creates and returns a new instance of
MarshallableOutBuilder initialized with the provided URL. |
default <T> T |
methodWriter(@NotNull Class<T> tClass,
Class<?>... additional)
Creates a proxy of the specified interfaces, where each method call on the proxy is written for replay.
|
default <T> @NotNull net.openhft.chronicle.bytes.MethodWriterBuilder<T> |
methodWriterBuilder(boolean metaData,
@NotNull Class<T> tClass)
Returns a
MethodWriterBuilder that can be used to create a proxy for an interface. |
default <T> @NotNull net.openhft.chronicle.bytes.MethodWriterBuilder<T> |
methodWriterBuilder(@NotNull Class<T> tClass)
Returns a
MethodWriterBuilder that can be used to create a proxy for an interface. |
default boolean |
recordHistory() |
default void |
writeBytes(@NotNull net.openhft.chronicle.bytes.WriteBytesMarshallable marshallable)
Serializes a Marshallable object directly to bytes.
|
default <T> void |
writeDocument(T t,
@NotNull BiConsumer<ValueOut,T> writer)
Writes a provided object using a custom marshalling mechanism specified by a
BiConsumer. |
default void |
writeDocument(@NotNull WriteMarshallable writer)
Writes a Marshallable object as a document or message.
|
default void |
writeMap(@NotNull Map<?,?> map)
Writes a provided map into the underlying
DocumentContext as a marshallable object. |
default void |
writeMessage(String eventName,
Object value)
Writes a message with a specified event name and associated object value.
|
default void |
writeMessage(WireKey key,
Object value)
Write a key and value which could be a scalar or a marshallable.
|
default void |
writeText(@NotNull CharSequence text)
Writes a provided text message into the underlying
DocumentContext. |
default @NotNull DocumentContext |
writingDocument()
Start a document which is completed when DocumentContext.close() is called.
|
DocumentContext |
writingDocument(boolean metaData)
Begins a new document-writing session with the option to include meta-data.
|
rollbackIfNotComplete, writingIsCompletestatic MarshallableOutBuilder builder(URL url)
MarshallableOutBuilder initialized with the provided URL.url - The URL which will dictate the specific type of MarshallableOut to create.MarshallableOutBuilder.@NotNull default @NotNull DocumentContext writingDocument() throws UnrecoverableTimeoutException
try(DocumentContext dc = appender.writingDocument()) {
dc.wire().write("message").text("Hello World");
}
WARNING : any data written inside the writingDocument(), should be performed as quickly as possible because a write lock is held until the DocumentContext is closed by the try-with-resources. For thread safe implementation such as Queue this blocks other appenders. Tailers are never blocked.
try (DocumentContext dc = appender.writingDocument()) {
// this should be performed as quickly as possible for implementations that support cocurrent writers
}
writingDocument in interface DocumentWrittenDocumentContext for writing.UnrecoverableTimeoutExceptionDocumentContext writingDocument(boolean metaData) throws UnrecoverableTimeoutException
DocumentContext once done writing.writingDocument in interface DocumentWrittenmetaData - Indicates if meta-data should be included in the document.DocumentContext.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.DocumentContext acquireWritingDocument(boolean metaData) throws UnrecoverableTimeoutException
acquireWritingDocument in interface DocumentWrittenmetaData - A boolean indicating if metadata should be included during writing.DocumentContext tailored to the metadata preference.UnrecoverableTimeoutException - If the operation times out in an unrecoverable manner.default boolean recordHistory()
default void writeMessage(WireKey key, Object value) throws UnrecoverableTimeoutException
key - to writevalue - to write with it.UnrecoverableTimeoutExceptiondefault void writeMessage(String eventName, Object value) throws UnrecoverableTimeoutException
DocumentContext, ensuring it's closed after the
message is written or if any exception occurs.eventName - The name of the event associated with the message.value - The object value to be written as part of the message.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.default void writeDocument(@NotNull
@NotNull WriteMarshallable writer)
throws UnrecoverableTimeoutException,
net.openhft.chronicle.core.io.InvalidMarshallableException
DocumentContext, ensuring it's closed after the document is written or if any exception occurs.writer - An instance of WriteMarshallable that knows how to serialize the object.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.net.openhft.chronicle.core.io.InvalidMarshallableException - if the object cannot be serialized properly.default void writeBytes(@NotNull
@NotNull net.openhft.chronicle.bytes.WriteBytesMarshallable marshallable)
throws UnrecoverableTimeoutException,
net.openhft.chronicle.core.io.InvalidMarshallableException
DocumentContext, ensuring it's closed after the serialization is done or if any exception occurs.marshallable - An instance of WriteBytesMarshallable that knows how to serialize the object to bytes.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.net.openhft.chronicle.core.io.InvalidMarshallableException - if the object cannot be serialized properly.default <T> void writeDocument(T t,
@NotNull
@NotNull BiConsumer<ValueOut,T> writer)
throws UnrecoverableTimeoutException,
net.openhft.chronicle.core.io.InvalidMarshallableException
BiConsumer.
This method allows clients to have custom serialization logic for any object.
The method also manages the lifecycle of the DocumentContext, ensuring it's closed after the object is
written or if any exception occurs.T - The type of the object to be serialized.t - The object to be serialized.writer - A BiConsumer that contains the custom serialization logic.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.net.openhft.chronicle.core.io.InvalidMarshallableException - if the object cannot be serialized properly.default void writeText(@NotNull
@NotNull CharSequence text)
throws UnrecoverableTimeoutException
DocumentContext. The method manages the lifecycle
of the context, ensuring it's closed after the text is written or if any exception occurs.text - The text message to be written.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.default void writeMap(@NotNull
@NotNull Map<?,?> map)
throws UnrecoverableTimeoutException
DocumentContext as a marshallable object. Each key-value
pair in the map is serialized individually. The method manages the lifecycle of the context, ensuring it's
closed after the map is written or if any exception occurs.map - The map to be serialized and written.UnrecoverableTimeoutException - if the operation times out in an unrecoverable manner.@NotNull
default <T> T methodWriter(@NotNull
@NotNull Class<T> tClass,
Class<?>... additional)
tClass - primary interfaceadditional - any additional interfaces@NotNull
default <T> @NotNull net.openhft.chronicle.bytes.MethodWriterBuilder<T> methodWriterBuilder(@NotNull
@NotNull Class<T> tClass)
MethodWriterBuilder that can be used to create a proxy for an interface.
Each message called on the proxy will be written for replay. This is a convenience method
that assumes metadata is not required.tClass - The primary interface that the builder will cater to.MethodWriterBuilder tailored for the given interface class.@NotNull
default <T> @NotNull net.openhft.chronicle.bytes.MethodWriterBuilder<T> methodWriterBuilder(boolean metaData,
@NotNull
@NotNull Class<T> tClass)
MethodWriterBuilder that can be used to create a proxy for an interface.
Depending on the metaData parameter, every method may be written as metadata. Each
message called on the proxy will be written to a file for method replay.metaData - If set to true, every method call will be written as metadata.tClass - The primary interface that the builder will cater to.MethodWriterBuilder tailored for the given interface class and metadata preference.Copyright © 2024. All rights reserved.