Class Message

java.lang.Object
io.elastic.api.Message
All Implemented Interfaces:
Serializable

public class Message extends Object implements Serializable
Message to be processed by a Function. A message may have a body, which represents a message's payload to be processed, and multiple attachments. Both body and attachments are JsonObjects.

A Function may retrieve a value from Message's body by a name, as shown in the following example.

 
    JsonArray orders = message.getBody().getJsonArray("orders");
 
 

A message is build using Message.Builder, as shown in the following example.

 
    JsonArray orders = JSON.parseArray(response.getOrders());

    JsonObject body = Json.createObjectBuilder()
            .add("orders", orders)
            .build();

    Message message = new Message.Builder().body(body).build();
 
 
See Also:
  • Field Details

  • Method Details

    • getId

      public UUID getId()
      Returns message id.
      Returns:
      id
    • getAttachments

      public jakarta.json.JsonObject getAttachments()
      Returns message attachments.
      Returns:
      attachments
    • getBody

      public jakarta.json.JsonObject getBody()
      Returns message body.
      Returns:
      body
    • getHeaders

      public jakarta.json.JsonObject getHeaders()
      Returns message headers.
      Returns:
      headers
    • getMethod

      public String getMethod()
      Returns message method.
      Returns:
      method
    • getOriginalUrl

      public String getOriginalUrl()
      Returns message originalUrl.
      Returns:
      originalUrl
    • getQuery

      public jakarta.json.JsonObject getQuery()
      Returns message query object.
      Returns:
      query
    • getPassthrough

      public jakarta.json.JsonObject getPassthrough()
      Returns message passthrough.
      Returns:
      passthrough
    • getUrl

      public String getUrl()
      Returns message URL.
      Returns:
      url
    • toJsonObject

      public jakarta.json.JsonObject toJsonObject()
      Returns this message as JsonObject.
      Returns:
      message as JSON object
    • toString

      public String toString()
      Overrides:
      toString in class Object