Interface Message

All Known Subinterfaces:
KafkaMessage, TracingMessage
All Known Implementing Classes:
AbstractMessage, DefaultMessage

public interface Message
  • Method Details

    • id

      String id()
      Get the current id of the message. The id may be null.
      Returns:
      the id of the message or null in case the message doesn't have any id.
    • correlationId

      String correlationId()
      The correlation id of the message. This id is never null and help to track messages across the gateway.
      Returns:
      the correlation id of the message.
    • parentCorrelationId

      String parentCorrelationId()
      The parent correlation id of the message. This id refers to a possible parent when the message has been created from another one.
      Returns:
      the parent correlation id of the message or null in case the message doesn't have any parent.
    • timestamp

      long timestamp()
      The timestamp for when this message was created.
      Returns:
      the instant timestamp for the message.
    • error

      boolean error()
      Flag indicating the message is in error. An error can occur during the processing. In that case, it is flagged in error to indicate that a special behavior may have to be applied for it.
      Returns:
      true if the message is in error, false otherwise.
    • error

      Message error(boolean error)
      Flag indicating the message is in error. An error can occur during the processing. In that case, it is flagged in error to indicate that a special behavior may have to be applied for it.
    • metadata

      Map<String,Object> metadata()
      Get the metadata of the message. Metadata are read-only. They usually come from the source that emits the message and can't be changed.
      Returns:
      the metadata of the message or an empty map if the message doesn't have any metadata.
    • headers

      HttpHeaders headers()
      Get the headers of the message.
      Returns:
      a read-write map of headers.
    • headers

      Message headers(HttpHeaders headers)
      Set the headers of the message.
      Parameters:
      headers - the headers to set on the message.
      Returns:
      reference to itself for easily chain calls.
    • content

      @Nullable @Nullable Buffer content()
      The current content of the message. The content may be of any type and is represented by a Buffer structure.
      Returns:
      the content of the message as a Buffer.
      See Also:
    • content

      Message content(Buffer content)
      Set the content of the message.
      Parameters:
      content - the buffer representing the content of the message.
      Returns:
      reference to itself for easily chain calls.
    • content

      Message content(String content)
      Set the content of the message.
      Parameters:
      content - the buffer representing the content of the message.
      Returns:
      reference to itself for easily chain calls.
    • ack

      void ack()
      MUST be called to acknowledge this message when it has been well-processed.
    • attribute

      <T> T attribute(String name)
      Returns the value of the attribute cast in the expected type T, or null if no attribute for the given name exists.
      Type Parameters:
      T - the expected type of the attribute value. Specify Object if you expect value of any type.
      Parameters:
      name - the name of the attribute.
      Returns:
      an Object containing the value of the attribute, or null if the attribute does not exist.
    • attributeAsList

      <T> List<T> attributeAsList(String name)
      Return the attribute as an immutable List. This method acts differently depending on the type of the attribute's value. Elements of the List are mapped as follows:

      For String:

      • comma separated string are spitted and returned trimmed
      • Parsable JSON Array elements are returned as strings (including objects)
      • if none of the above, the string is simply wrapped

      For Collection:

      • Elements of the collection are wrapped in a new List

      For Array:

      • Each elements of the is wrapped into the returned List

      For any other cases: the value is simply wrapped into the returned List. Notes: One calling attribute(String, Object) with a mutable collection will retrieve an immutable one.

      Type Parameters:
      T - the expected type of the attribute value. Specify Object if you expect value of any type.
      Parameters:
      name - the name of the attribute.
      Returns:
      an immutable List with the attribute values.
    • attribute

      Message attribute(String name, Object value)
      Stores an attribute in this message.
      Parameters:
      name - a String specifying the name of the attribute.
      value - the Object to be stored.Returns:
      Returns:
      reference to itself for easily chain calls
    • removeAttribute

      Message removeAttribute(String name)
      Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the message is being handled.
      Parameters:
      name - the name of the attribute to remove.
      Returns:
      reference to itself for easily chain calls
    • attributeNames

      Set<String> attributeNames()
      Returns a Set containing the names of the attributes available to this message. This method returns an empty Set if the message has no attributes available to it.
      Returns:
      a set of strings containing the names of the message's attributes.
    • attributes

      <T> Map<String,T> attributes()
      Get all attributes available.
      Type Parameters:
      T - the expected type of the attribute values. Specify Object if you expect values of any types.
      Returns:
      the list of all the attributes.
    • internalAttribute

      <T> T internalAttribute(String name)
    • internalAttribute

      Message internalAttribute(String name, Object value)
      Stores an internal attribute in this message. Internal attributes can be used to avoid mixin with attributes set by the user during the request processing.. You can safely use internal attribute to temporary store useful objects required during different phases of the execution.
      Parameters:
      name - a String specifying the name of the attribute.
      value - the Object to be stored.Returns:
      Returns:
      reference to itself for easily chain calls
    • removeInternalAttribute

      Message removeInternalAttribute(String name)
      Removes an internal attribute from this request. This method is not generally needed as internal attributes only persist as long as the message is being handled.
      Parameters:
      name - the name of the internal attribute to remove.
      Returns:
      reference to itself for easily chain calls.
    • internalAttributeNames

      Set<String> internalAttributeNames()
      Returns a Set containing the names of the internal attributes available to this message. This method returns an empty Set if the message has no internal attributes available to it.
      Returns:
      a set of strings containing the names of the message's internal attributes.
    • internalAttributes

      <T> Map<String,T> internalAttributes()
      Get all internal attributes available. Internal attributes are not intended to be manipulated by end-users. You can safely use internal attribute to temporary store useful objects required during different phases of the execution.
      Type Parameters:
      T - the expected type of the internal attribute values. Specify Object if you expect values of any types.
      Returns:
      the list of all the internal attributes.