Class Message
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FileMessage, PartMessage, PathMessage, UrlMessage
Serializable wrapper around data passed to the Frank!Framework and between pipes in the
pipeline.
Regardless of the original format of the data, the system will always allow repeatable access to the data
in multiple formats, such as InputStream, Reader, byte[], String and
for XML data, also as InputSource or Source.
The Frank!Framework will intelligently buffer message data to memory or disk depending on size and configured limits. The limit for data held in memory is controlled via property "message.max.memory.size". The default value is 5242880L.
Operations on a Message that change state, such as serializing the Message are
not thread-safe. If there is a chance that these operations are simultaneously executed from multiple threads, they need to be
wrapped in a synchronized block that synchronizes on the message instance.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final Stringstatic final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionMessage(byte[] request) Message(byte[] request, MessageContext context) Message(InputStream request) Message(InputStream request, String charset) Message(InputStream request, MessageContext context) protectedMessage(InputStream request, MessageContext context, Class<?> requestClass) Message(Reader request, MessageContext context) Message(String request, MessageContext context) protectedMessage(ThrowingSupplier<InputStream, Exception> request, MessageContext context, Class<?> requestClass) Constructor for Message using InputStream supplier.protectedMessage(SerializableFileReference request, MessageContext context, Class<?> requestClass) Constructor for Message using aSerializableFileReference.Message(Node request, MessageContext context) -
Method Summary
Modifier and TypeMethodDescriptionbyte @Nullable []Return the request object as a byte array.byte @Nullable []asByteArray(@Nullable String defaultEncodingCharset) Return the request object as a byte array with the specified character encoding.@Nullable InputSourcereturn the request object as aInputSource.Return anInputStreambacked by the data in this message.asInputStream(@Nullable String defaultEncodingCharset) Return anInputStreambacked by the data in this message.static MessagePlease note that this method should only be used when you don't know the type of object.@Nullable ObjectasObject()Deprecated.Please avoid the use of the raw object wherever possible and if you must, annotate why.asReader()Return aReaderbacked by the data in this message.@Nullable SourceasSource()return the request object as aSource.@Nullable StringasString()return the request object as a String.Creates a copy of this Message object.@Nullable StringRepresenting a charset of binary requestsReturns the message identifier and which resource class it representsbooleanisBinary()booleanisEmpty()Check if a message is empty.static booleanCheck if the message passed is null or empty.static booleanisFormattedErrorMessage(@Nullable Message message) booleanisNull()static booleanbooleanisRequestOfType(Class<?> clazz) static Messagestatic MessagenullMessage(MessageContext context) peek(int readLimit) booleanIf true, the Message should preferably be read using a streaming method, i.e. asReader() or asInputStream(), to avoid copying it into memory.voidsetCharset(@Nullable String charset) voidsetCharset(@Nullable Charset charset) longsize()toString()toString can be used to inspect the message.
-
Field Details
-
MESSAGE_SIZE_UNKNOWN
public static final long MESSAGE_SIZE_UNKNOWN- See Also:
-
MESSAGE_MAX_IN_MEMORY_DEFAULT
public static final long MESSAGE_MAX_IN_MEMORY_DEFAULT- See Also:
-
MESSAGE_MAX_IN_MEMORY_PROPERTY
- See Also:
-
MESSAGE_MAX_IN_MEMORY
public static final long MESSAGE_MAX_IN_MEMORY
-
-
Constructor Details
-
Message
-
Message
-
Message
-
Message
-
Message
public Message(byte[] request) -
Message
- Throws:
IOException
-
Message
- Throws:
IOException
-
Message
protected Message(ThrowingSupplier<InputStream, Exception> request, MessageContext context, Class<?> requestClass) Constructor for Message using InputStream supplier. It is assumed the InputStream can be supplied multiple times. -
Message
Constructor for Message using aSerializableFileReference.- Parameters:
request- Request asSerializableFileReferencecontext-MessageContextrequestClass-Classof the original request from which theSerializableFileReferencerequest was created
-
Message
- Throws:
IOException
-
Message
- Throws:
IOException
-
Message
protected Message(InputStream request, MessageContext context, Class<?> requestClass) throws IOException - Throws:
IOException
-
Message
- Throws:
IOException
-
Message
-
Message
-
-
Method Details
-
nullMessage
-
nullMessage
-
copyContext
-
getCharset
Representing a charset of binary requests- Returns:
- the charset provided when the message was created
-
setCharset
-
setCharset
-
asObject
Deprecated.Please avoid the use of the raw object wherever possible and if you must, annotate why. -
isBinary
public boolean isBinary() -
requiresStream
public boolean requiresStream()If true, the Message should preferably be read using a streaming method, i.e. asReader() or asInputStream(), to avoid copying it into memory. -
asReader
Return aReaderbacked by the data in this message.Reader.markSupported()is guaranteed to be true for the returned stream.- Throws:
IOException
-
asInputStream
Return anInputStreambacked by the data in this message.InputStream.markSupported()is guaranteed to be true for the returned stream.- Throws:
IOException
-
asInputStream
Return anInputStreambacked by the data in this message.InputStream.markSupported()is guaranteed to be true for the returned stream.- Parameters:
defaultEncodingCharset- is only used when the Message object is of character type (String)- Throws:
IOException
-
peek
- Throws:
IOException
-
asInputSource
return the request object as aInputSource.- Throws:
IOException
-
asSource
return the request object as aSource.- Throws:
IOExceptionSAXException
-
asByteArray
Return the request object as a byte array.- Throws:
IOException
-
asByteArray
Return the request object as a byte array with the specified character encoding.- Throws:
IOException
-
asString
return the request object as a String. This may have the side effect of preserving the input as a String, thus modifying the state of the Message object. This operation is not thread-safe.- Throws:
IOException
-
isNull
public boolean isNull() -
isRequestOfType
- Returns:
- true if the request is or extends of the specified type at parameter clazz
-
isEmpty
public boolean isEmpty()Check if a message is empty. If message size cannot be determined, check if any data can be read from the message.- Returns:
trueif the message is empty or no data can be read from it,falseif the size if larger than 0 or data can be read from it.
-
toString
-
getObjectId
Returns the message identifier and which resource class it represents- Returns:
- Message[1234abcd:ByteArrayInputStream]
-
asMessage
Please note that this method should only be used when you don't know the type of object. In all other cases, use the constructor ofMessageor a more applicable subclass likeFileMessageorUrlMessage- Returns:
- a Message of the correct type for the given object
-
isEmpty
-
isNull
-
size
public long size()- Returns:
- Message size or -1 if it can't determine the size.
-
copyMessage
Creates a copy of this Message object.NB: To copy the underlying value of the message object, the message may be preserved if it was not repeatable. Thus this operation may modify the state of the message object.
- Returns:
- A new Message object that is a copy of this Message.
- Throws:
IOException- If an I/O error occurs during the copying process.
-
isFormattedErrorMessage
-