Package org.apache.activemq.artemis.api.core.client

## Interface ClientMessage

- All Superinterfaces:
    `ICoreMessage`, `Message`

      public interface ClientMessage
      extends ICoreMessage

  A ClientMessage represents a message sent and/or received by ActiveMQ Artemis.

- - ### Field Summary

    - ### Fields inherited from interface org.apache.activemq.artemis.api.core.Message

      `BYTES_TYPE, DEFAULT_TYPE, EMBEDDED_TYPE, HDR_ACTUAL_EXPIRY_TIME, HDR_BRIDGE_DUPLICATE_ID, HDR_CONTENT_TYPE, HDR_DUPLICATE_DETECTION_ID, HDR_GROUP_ID, HDR_GROUP_SEQUENCE, HDR_INGRESS_TIMESTAMP, HDR_LARGE_BODY_SIZE, HDR_LARGE_COMPRESSED, HDR_LAST_VALUE_NAME, HDR_ORIG_MESSAGE_ID, HDR_ORIG_ROUTING_TYPE, HDR_ORIGINAL_ADDRESS, HDR_ORIGINAL_QUEUE, HDR_PREFIX, HDR_ROUTE_TO_ACK_IDS, HDR_ROUTE_TO_IDS, HDR_ROUTING_TYPE, HDR_SCALEDOWN_TO_IDS, HDR_SCHEDULED_DELIVERY_TIME, HDR_VALIDATED_USER, INTERNAL_PROPERTY_NAMES_PREDICATE, LARGE_EMBEDDED_TYPE, MAP_TYPE, memoryOffset, OBJECT_TYPE, STREAM_TYPE, TEXT_TYPE`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ClientMessage` | `acknowledge()` | Acknowledges reception of this message.
    `void` | `checkCompletion()` | This can be optionally used to verify if the entire message has been received.
    `org.apache.activemq.artemis.api.core.ActiveMQBuffer` | `getBodyBuffer()` | The buffer to write the body.
    `java.io.InputStream` | `getBodyInputStream()` | Return the bodyInputStream for large messages
    `int` | `getBodySize()` | Returns the size (in bytes) of this message's body
    `int` | `getDeliveryCount()` | Returns the number of times this message was delivered.
    `ClientMessage` | `individualAcknowledge()` | Acknowledges reception of a single message.
    `ClientMessage` | `putBooleanProperty​(java.lang.String key, boolean value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putBooleanProperty​(org.apache.activemq.artemis.api.core.SimpleString key, boolean value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putByteProperty​(java.lang.String key, byte value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putByteProperty​(org.apache.activemq.artemis.api.core.SimpleString key, byte value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putBytesProperty​(java.lang.String key, byte[] value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putBytesProperty​(org.apache.activemq.artemis.api.core.SimpleString key, byte[] value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putCharProperty​(java.lang.String key, char value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putCharProperty​(org.apache.activemq.artemis.api.core.SimpleString key, char value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putDoubleProperty​(java.lang.String key, double value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putDoubleProperty​(org.apache.activemq.artemis.api.core.SimpleString key, double value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putFloatProperty​(java.lang.String key, float value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putFloatProperty​(org.apache.activemq.artemis.api.core.SimpleString key, float value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putIntProperty​(java.lang.String key, int value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putIntProperty​(org.apache.activemq.artemis.api.core.SimpleString key, int value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putLongProperty​(java.lang.String key, long value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putLongProperty​(org.apache.activemq.artemis.api.core.SimpleString key, long value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putShortProperty​(java.lang.String key, short value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putShortProperty​(org.apache.activemq.artemis.api.core.SimpleString key, short value)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `putStringProperty​(java.lang.String key, java.lang.String value)` | Overridden from `Message` to enable fluent API
    `void` | `saveToOutputStream​(java.io.OutputStream out)` | Saves the content of the message to the OutputStream.
    `ClientMessage` | `setBodyInputStream​(java.io.InputStream bodyInputStream)` | Sets the body's IntputStream.
    `ClientMessage` | `setDeliveryCount​(int deliveryCount)` | Sets the delivery count for this message.
    `ClientMessage` | `setOutputStream​(java.io.OutputStream out)` | Sets the OutputStream that will receive the content of a message received in a non blocking way.
    `boolean` | `waitOutputStreamCompletion​(long timeMilliseconds)` | Wait the outputStream completion of the message.
    `ClientMessage` | `writeBodyBufferBytes​(byte[] bytes)` | Overridden from `Message` to enable fluent API
    `ClientMessage` | `writeBodyBufferString​(java.lang.String string)` | Overridden from `Message` to enable fluent API

    - ### Methods inherited from interface org.apache.activemq.artemis.api.core.ICoreMessage

      `getBodyBufferSize, getBuffer, getDataBuffer, getEndOfBodyPosition, getHeadersAndPropertiesEncodeSize, getLargeBodyReader, getReadOnlyBodyBuffer, getType, isServerMessage, moveHeadersAndProperties, receiveBuffer_1X, sendBuffer_1X, setBuffer, setType, toMap`

    - ### Methods inherited from interface org.apache.activemq.artemis.api.core.Message

      `acceptsConsumer, clearInternalProperties, containsProperty, containsProperty, copy, copy, copy, durableDown, durableUp, getAddress, getAddressSimpleString, getAnnotation, getAnnotationString, getBooleanProperty, getBooleanProperty, getBrokerProperty, getByteProperty, getByteProperty, getBytesProperty, getBytesProperty, getConnectionID, getCorrelationID, getDoubleProperty, getDoubleProperty, getDuplicateIDBytes, getDuplicateProperty, getDurableCount, getEncodeSize, getExpiration, getExtraBytesProperty, getFloatProperty, getFloatProperty, getGroupID, getGroupSequence, getIngressTimestamp, getIntProperty, getIntProperty, getLastValueProperty, getLongProperty, getLongProperty, getMemoryEstimate, getMessageID, getObjectProperty, getObjectProperty, getObjectPropertyForFilter, getOwner, getPersistentSize, getPersister, getPersistSize, getPriority, getPropertyNames, getProtocolName, getRefCount, getReplyTo, getRoutingType, getScheduledDeliveryTime, getShortProperty, getShortProperty, getSimpleStringProperty, getSimpleStringProperty, getStringBody, getStringProperty, getStringProperty, getTimestamp, getUsage, getUserContext, getUserID, getValidatedUserID, getWholeMessageSize, hasScheduledDeliveryTime, isDurable, isExpired, isLargeMessage, messageChanged, persist, putExtraBytesProperty, putObjectProperty, putObjectProperty, putStringProperty, putStringProperty, receiveBuffer, reencode, refDown, referenceOriginalMessage, refUp, rejectConsumer, reloadPersistence, removeAnnotation, removeExtraBytesProperty, removeProperty, removeProperty, sendBuffer, setAddress, setAddress, setAnnotation, setBrokerProperty, setConnectionID, setCorrelationID, setDurable, setExpiration, setGroupID, setGroupID, setGroupSequence, setIngressTimestamp, setLastValueProperty, setMessageID, setOwner, setPriority, setReplyTo, setRoutingType, setScheduledDeliveryTime, setTimestamp, setUserContext, setUserID, setValidatedUserID, toCompositeData, toCore, toCore, toMap, toPropertyMap, toPropertyMap, usageDown, usageUp`

- - ### Method Detail

    - #### getDeliveryCount

          int getDeliveryCount()

      Returns the number of times this message was delivered.

    - #### setDeliveryCount

          ClientMessage setDeliveryCount​(int deliveryCount)

      Sets the delivery count for this message.

      This method is not meant to be called by ActiveMQ Artemis clients.

      Parameters:
        `deliveryCount` - message delivery count
      Returns:
        this ClientMessage

    - #### acknowledge

          ClientMessage acknowledge()
                             throws org.apache.activemq.artemis.api.core.ActiveMQException

      Acknowledges reception of this message.

      If the session responsible to acknowledge this message has `autoCommitAcks` set to `true`, the transaction will automatically commit the current transaction. Otherwise, this acknowledgement will not be committed until the client commits the session transaction.

      Throws:
        `org.apache.activemq.artemis.api.core.ActiveMQException` - if an error occurred while acknowledging the message.
      See Also:
        `ClientSession.isAutoCommitAcks()`

    - #### individualAcknowledge

          ClientMessage individualAcknowledge()
                                       throws org.apache.activemq.artemis.api.core.ActiveMQException

      Acknowledges reception of a single message.

      If the session responsible to acknowledge this message has `autoCommitAcks` set to `true`, the transaction will automatically commit the current transaction. Otherwise, this acknowledgement will not be committed until the client commits the session transaction.

      Throws:
        `org.apache.activemq.artemis.api.core.ActiveMQException` - if an error occurred while acknowledging the message.
      See Also:
        `ClientSession.isAutoCommitAcks()`

    - #### checkCompletion

          void checkCompletion()
                        throws org.apache.activemq.artemis.api.core.ActiveMQException

      This can be optionally used to verify if the entire message has been received. It won't have any effect on regular messages but it may be helpful on large messages. The use case for this is to make sure there won't be an exception while getting the buffer. Using getBodyBuffer directly would have the same effect but you could get a Runtime non checked Exception instead
      Throws:
        `org.apache.activemq.artemis.api.core.ActiveMQException`

    - #### getBodySize

          int getBodySize()

      Returns the size (in bytes) of this message's body

    - #### setOutputStream

          ClientMessage setOutputStream​(java.io.OutputStream out)
                                 throws org.apache.activemq.artemis.api.core.ActiveMQException

      Sets the OutputStream that will receive the content of a message received in a non blocking way.
      This method is used when consuming large messages
      Returns:
        this ClientMessage
      Throws:
        `org.apache.activemq.artemis.api.core.ActiveMQException`

    - #### saveToOutputStream

          void saveToOutputStream​(java.io.OutputStream out)
                           throws org.apache.activemq.artemis.api.core.ActiveMQException

      Saves the content of the message to the OutputStream. It will block until the entire content is transferred to the OutputStream.
      Throws:
        `org.apache.activemq.artemis.api.core.ActiveMQException`

    - #### waitOutputStreamCompletion

          boolean waitOutputStreamCompletion​(long timeMilliseconds)
                                      throws org.apache.activemq.artemis.api.core.ActiveMQException

      Wait the outputStream completion of the message. This method is used when consuming large messages
      Parameters:
        `timeMilliseconds` - - 0 means wait forever
      Returns:
        true if it reached the end
      Throws:
        `org.apache.activemq.artemis.api.core.ActiveMQException`

    - #### setBodyInputStream

          ClientMessage setBodyInputStream​(java.io.InputStream bodyInputStream)

      Sets the body's IntputStream.
      This method is used when sending large messages
      Returns:
        this ClientMessage

    - #### getBodyInputStream

          java.io.InputStream getBodyInputStream()

      Return the bodyInputStream for large messages
      Specified by:
        `getBodyInputStream` in interface `ICoreMessage`
      Specified by:
        `getBodyInputStream` in interface `Message`
      Returns:

    - #### getBodyBuffer

          org.apache.activemq.artemis.api.core.ActiveMQBuffer getBodyBuffer()

      The buffer to write the body. Warning: If you just want to read the content of a message, use getDataBuffer() or getReadOnlyBuffer();
      Specified by:
        `getBodyBuffer` in interface `ICoreMessage`
      Specified by:
        `getBodyBuffer` in interface `Message`
      Returns:

    - #### putBooleanProperty

          ClientMessage putBooleanProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                           boolean value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putBooleanProperty` in interface `Message`

    - #### putBooleanProperty

          ClientMessage putBooleanProperty​(java.lang.String key,
                                           boolean value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putBooleanProperty` in interface `Message`

    - #### putByteProperty

          ClientMessage putByteProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                        byte value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putByteProperty` in interface `Message`

    - #### putByteProperty

          ClientMessage putByteProperty​(java.lang.String key,
                                        byte value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putByteProperty` in interface `Message`

    - #### putBytesProperty

          ClientMessage putBytesProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                         byte[] value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putBytesProperty` in interface `Message`

    - #### putBytesProperty

          ClientMessage putBytesProperty​(java.lang.String key,
                                         byte[] value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putBytesProperty` in interface `Message`

    - #### putShortProperty

          ClientMessage putShortProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                         short value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putShortProperty` in interface `Message`

    - #### putShortProperty

          ClientMessage putShortProperty​(java.lang.String key,
                                         short value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putShortProperty` in interface `Message`

    - #### putCharProperty

          ClientMessage putCharProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                        char value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putCharProperty` in interface `Message`

    - #### putCharProperty

          ClientMessage putCharProperty​(java.lang.String key,
                                        char value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putCharProperty` in interface `Message`

    - #### putIntProperty

          ClientMessage putIntProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                       int value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putIntProperty` in interface `Message`

    - #### putIntProperty

          ClientMessage putIntProperty​(java.lang.String key,
                                       int value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putIntProperty` in interface `Message`

    - #### putLongProperty

          ClientMessage putLongProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                        long value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putLongProperty` in interface `Message`

    - #### putLongProperty

          ClientMessage putLongProperty​(java.lang.String key,
                                        long value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putLongProperty` in interface `Message`

    - #### putFloatProperty

          ClientMessage putFloatProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                         float value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putFloatProperty` in interface `Message`

    - #### putFloatProperty

          ClientMessage putFloatProperty​(java.lang.String key,
                                         float value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putFloatProperty` in interface `Message`

    - #### putDoubleProperty

          ClientMessage putDoubleProperty​(org.apache.activemq.artemis.api.core.SimpleString key,
                                          double value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putDoubleProperty` in interface `Message`

    - #### putDoubleProperty

          ClientMessage putDoubleProperty​(java.lang.String key,
                                          double value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putDoubleProperty` in interface `Message`

    - #### putStringProperty

          ClientMessage putStringProperty​(java.lang.String key,
                                          java.lang.String value)

      Overridden from `Message` to enable fluent API
      Specified by:
        `putStringProperty` in interface `Message`
      Parameters:
        `key` - property name
        `value` - property value

    - #### writeBodyBufferBytes

          ClientMessage writeBodyBufferBytes​(byte[] bytes)

      Overridden from `Message` to enable fluent API

    - #### writeBodyBufferString

          ClientMessage writeBodyBufferString​(java.lang.String string)

      Overridden from `Message` to enable fluent API