Setting Message Properties

The following sections discuss some important message properties that can be set for messages to be published. These properties can affect how messages are routed.

Time-to-Live

To ensure that stale messages are not consumed, you can set a Time‑To-Live (TTL) value (in milliseconds) for each Guaranteed message published by a producer. The TTL value is ignored for non‑durable endpoints when using Direct Transport.

Respecting TTL

If destination queues or topic endpoints are configured to respect message TTLs, when received messages’ TTLs have passed, they are either discarded by the endpoint, or, if the messages are eligible for a Dead Message Queue (DMQ), they are moved to a DMQ provisioned on the event broker.

:  The respect-ttl property value set at the connectionFactory level can be overridden through the InitialContext environment using SupportedProperty.SOLACE_JMS_RESPECT_TIME_TO_LIVE.

Setting TTL

You can set a TTL value for messages in the following ways:

  • Call MessageProducer.setTimeToLive(long timeToLive) to set a default TTL value for all messages to be published by the MessageProducer. (A value of 0 means that the messages never expire.)
  • After acquiring a MessageProducer, a TTL value can be passed in when you call either one of the following methods to publish the message:
    • send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) or send(Message message, int deliveryMode, int priority, long timeToLive)

    The TTL value set through these methods overrides any set at the MessageProducer level.

Moving messages to a DMQ

If you want to move messages with expired TTL values to a provisioned DMQ, the endpoints must be configured to respect the messages’ TTL values:

  • If you are using SolAdmin to provision endpoints, you must enable the Respect TTL check box and create a new queue or subscription name (that is, endpoint).
  • If you want to dynamically create endpoints, the connectionFactory used should also be configured to respect TTLs. Therefore, when using SolAdmin to create a connectionFactory, enable the Respect TTL check box. When using the CLI to create the connectionFactory, set respect‑ttl to true. For more information, refer to Solace JNDI Objects.

Delayed message consumption

TTL can be used to implement delayed message consumption. It allows messages to be published at one time and consumed at some later time, where you specify the lag between publication and consumption. For instructions on how to set up and use the feature, refer to Delayed Message Consumption.

Dead Message Queue Eligibility

Guaranteed messages that have exceeded their TTL, or maximum number of redelivery attempts, can be moved from a durable Queue or a Topic Endpoint to a DMQ, instead of being discarded if those messages are flagged as being DMQ-eligible. A DMQ is just a durable queue that has been assigned to serve as the DMQ for another durable endpoint. For more information, refer to Dead Message Queues.

You can dynamically create a queue with the name #DEAD_MSG_QUEUE through the JMS API (refer to Creating Queues), or provision one through CLI or SolAdmin.

You can flag published messages as DMQ eligible on a per-message basis, or you can enable message eligibility for DMQs on a Connection Factory basis so that all messages published by Producers using that Connection Factory are DMQ-eligible.

  • To flag individual messages
  • Set the SOLACE_JMS_PROP_DEAD_MSG_QUEUE_ELIGIBLE property to true for each message.

  • To flag messages at the Connection Factory level
  • Use SolAdmin or the CLI to enable the default-dmq-eligible property.

For more information on this message property, refer to Dead Message Queue Eligible.

Eliding Eligibility

The message eliding capabilities of Solace PubSub+ enables client applications to only receive the most current messages published to topics that they subscribe to, at a rate that they can manage. Using message eliding can be useful in situations where a slower message rate is required or where there are slow consumers.

To use message eliding, the following steps are required:

  • A consuming client application must be assigned a client profile through its client username that permits it to use message eliding. The client profile also sets a rate to control the delay interval at which a new eliding-eligible message elides a previous version that is queued for delivery to the client.
  • Published messages must be flagged as eligible for message eliding.
  • You can flag published messages as eligible for message eliding on a per‑message basis, or you can enable message eliding eligibility on a Connection Factory basis so that all messages published by Producers using that Connection Factory are eliding-eligible.
    • To flag individual messages, set the SOLACE_JMS_PROP_ELIDING_ELIGIBLE property to true for each message.
    • To flag messages at the Connection Factory level, use SolAdmin or the CLI to enable the default-eliding-eligible property.

For more information on this message property, refer to Eliding Eligible.