Package oracle.jdbc.aq

## Interface AQMessageProperties

    public interface AQMessageProperties

This interface contains the message properties such as Correlation, Sender, Delay and Expiration, Recipients, and Priority and Ordering. Some of these properties such as the enqueue timestamp or the count of dequeue attempts cannot be set by the user: they are retrieved from the server during a dequeue operation.

When enqueuing a new message in a queue, you first need to retrieve a new instance of this interface by calling `AQFactory.createAQMessageProperties()`. Fill the message properties and then call `AQFactory.createAQMessage(props)` to create a new AQ message with `props` being the message properties. Finally set the payload and then enqueue the message.

Since:
  11.1
See Also:
  `AQFactory.createAQMessageProperties`

### Nested Class Summary

Nested Classes
`static class` `AQMessageProperties.DeliveryMode`
`static class` `AQMessageProperties.MessageState`

### Field Summary

Fields
`static int` `INVALID_SHARD_ID` Used in the context of the Shard Id hint to represent an invalid Shard.
`static int` `MESSAGE_NO_DELAY` Possible value for setDelay.
`static int` `MESSAGE_NO_EXPIRATION` The message will never expire.

### Method Summary

All Methods Instance Methods Abstract Methods
`java.lang.String` `getCorrelation()`
`int` `getDelay()`
`AQMessageProperties.DeliveryMode` `getDeliveryMode()` After a dequeue operation, call this method to find out if the message was enqueued in a persistent manner or not.
`int` `getDequeueAttemptsCount()` Returns the number of attempts that have been made to dequeue the message.
`java.sql.Timestamp` `getEnqueueTime()` Returns the time the message was enqueued.
`java.lang.String` `getExceptionQueue()`
`int` `getExpiration()`
`byte[]` `getPreviousQueueMessageId()` The ID of the message in the last queue that generated this message.
`int` `getPriority()`
`AQAgent[]` `getRecipientList()`
`AQAgent` `getSender()`
`int` `getShardNum()`
`AQMessageProperties.MessageState` `getState()` Returns the state of the message at the time of the dequeue.
`java.lang.String` `getTransactionGroup()` For transaction-grouped queues, this identifies the transaction group of the message.
`void` `setCorrelation​(java.lang.String correlation)` Specifies the identification supplied by the producer for a message at enqueuing.
`void` `setDelay​(int delay)` Specifies the number of seconds to delay the enqueued message.
`void` `setExceptionQueue​(java.lang.String exceptionQueue)` Specifies the name of the queue to which the message is moved to if it cannot be processed successfully.
`void` `setExpiration​(int seconds)` Specifies the expiration of the message.
`void` `setPriority​(int priority)` Specifies the priority of the message.
`void` `setRecipientList​(AQAgent[] agents)` This parameter is only valid for queues which allow multiple consumers.
`void` `setSender​(AQAgent sender)` Identifies the original sender of a message.
`void` `setShardNum​(int shardNum)` Specifies ShardID of the message.
`java.lang.String` `toString()`

### Field Detail

#### MESSAGE_NO_DELAY

    static final int MESSAGE_NO_DELAY

Possible value for setDelay. Indicates the message is available for immediate dequeuing.

See Also:
  Constant Field Values

#### MESSAGE_NO_EXPIRATION

    static final int MESSAGE_NO_EXPIRATION

The message will never expire. Can be used for setExpiration().

See Also:
  Constant Field Values

#### INVALID_SHARD_ID

    static final int INVALID_SHARD_ID

Used in the context of the Shard Id hint to represent an invalid Shard.

See Also:
  Constant Field Values

### Method Detail

#### getDequeueAttemptsCount

    int getDequeueAttemptsCount()

Returns the number of attempts that have been made to dequeue the message.

#### setCorrelation

    void setCorrelation​(java.lang.String correlation)
                 throws java.sql.SQLException

Specifies the identification supplied by the producer for a message at enqueuing.

Throws:
  `java.sql.SQLException`

#### getCorrelation

    java.lang.String getCorrelation()

#### setDelay

    void setDelay​(int delay)
           throws java.sql.SQLException

Specifies the number of seconds to delay the enqueued message. The delay represents the number of seconds after which a message is available for dequeuing. Dequeuing by msgid overrides the delay specification. A message enqueued with delay set will be in the WAITING state, when the delay expires the messages goes to the READY state. DELAY processing requires the queue monitor to be started. Note that delay is set by the producer who enqueues the message.

Throws:
  `java.sql.SQLException`

#### getDelay

    int getDelay()

#### getEnqueueTime

    java.sql.Timestamp getEnqueueTime()

Returns the time the message was enqueued. This value is determined by the system and cannot be set by the user.

#### setExceptionQueue

    void setExceptionQueue​(java.lang.String exceptionQueue)
                    throws java.sql.SQLException

Specifies the name of the queue to which the message is moved to if it cannot be processed successfully. Messages are moved in two cases: If the number of unsuccessful dequeue attempts has exceeded max_retries; or if the message has expired. All messages in the exception queue are in the EXPIRED state. The default is the exception queue associated with the queue table. If the exception queue specified does not exist at the time of the move the message will be moved to the default exception queue associated with the queue table and a warning will be logged in the alert file. If the default exception queue is used, the parameter will return a NULL value at dequeue time. This attribute must refer to a valid queue name.

Throws:
  `java.sql.SQLException`

#### getExceptionQueue

    java.lang.String getExceptionQueue()

#### setExpiration

    void setExpiration​(int seconds)
                throws java.sql.SQLException

Specifies the expiration of the message. It determines, in seconds, the duration the message is available for dequeuing. This parameter is an offset from the delay. Expiration processing requires the queue monitor to be running. While waiting for expiration, the message remains in the READY state. If the message is not dequeued before it expires, it will be moved to the exception queue in the EXPIRED state.

Throws:
  `java.sql.SQLException`

#### getExpiration

    int getExpiration()

#### getState

    AQMessageProperties.MessageState getState()

Returns the state of the message at the time of the dequeue. This parameter cannot be set at enqueue time.

#### setPriority

    void setPriority​(int priority)
              throws java.sql.SQLException

Specifies the priority of the message. A smaller number indicates higher priority. The priority can be any number, including negative numbers. The default value is zero.

Throws:
  `java.sql.SQLException`

#### getPriority

    int getPriority()

#### setShardNum

    void setShardNum​(int shardNum)
              throws java.sql.SQLException

Specifies ShardID of the message. ShardID can be any integer, including negative number. Default value is INVALID_SHARD_ID.

Throws:
  `java.sql.SQLException`

#### getShardNum

    int getShardNum()

#### setRecipientList

    void setRecipientList​(AQAgent[] agents)
                   throws java.sql.SQLException

This parameter is only valid for queues which allow multiple consumers. The default recipients are the queue subscribers but they can be overridden using this method. This parameter is not returned to a consumer at dequeue time.

Throws:
  `java.sql.SQLException`

#### getRecipientList

    AQAgent[] getRecipientList()

#### setSender

    void setSender​(AQAgent sender)
            throws java.sql.SQLException

Identifies the original sender of a message.

Throws:
  `java.sql.SQLException`

#### getSender

    AQAgent getSender()

#### getTransactionGroup

    java.lang.String getTransactionGroup()

For transaction-grouped queues, this identifies the transaction group of the message. This attribute is populated after a successful dequeueArray() call. All messages in a group have the same value for this attribute. This attribute cannot be used by the enqueueArray() call to set the transaction group for an enqueued message.

#### getPreviousQueueMessageId

    byte[] getPreviousQueueMessageId()

The ID of the message in the last queue that generated this message. When a message is propagated from one queue to another, this attribute identifies the ID of the queue from which it was last propagated. When a message has been propagated through multiple queues, this attribute identifies the ID of the message in the last queue that generated this message, not the first queue.

#### getDeliveryMode

    AQMessageProperties.DeliveryMode getDeliveryMode()

After a dequeue operation, call this method to find out if the message was enqueued in a persistent manner or not.

Note that this is set at dequeue time by the driver. There is an enqueue option to enqueue a buffered message.

#### toString

    java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`