Delivering Messages to Single Consumers
Solace PubSub+ event brokers support a Deliver‑To‑One feature that allows a producer to specify that if a message it sends matches subscriptions for multiple Direct Transport clients on an event broker, it can only be delivered to at most one of them. This feature is useful for implementing load balancing across a group of consumers.
The Deliver-To-One feature has the following constraints when used with JMS:
- The Deliver-To-One feature can only be specified for Non-Persistent messages sent using the Direct Transport delivery mode.
- The group of Deliver-To-One consumers must be bound to non-durable endpoints using Direct Transport with a single consumer per connection.
The Deliver-To-One behavior for producers is specified by the
deliver-to-one JNDI Connection Factory property. If this property is set to
true, producers for that connection send all messages using the Deliver-To-One feature.
However, it is possible to enable or disable the feature on a per-message basis using the
SOLACE_JMS_PROP_DELIVER_TO_ONE property. This message property overrides the Connection Factory setting. For example, to ensure that a message is sent using the Deliver-To-One feature, the message property can be set as follows:
TextMessage message = session.createTextMessage("text message"); message.setBooleanProperty(SupportedProperty.SOLACE_JMS_PROP_DELIVER_TO_ONE, true);
By default, the Deliver-To-One override is enabled in the Connection Factory, and consumers created with that default Connection Factory setting connect to the event broker using a Deliver-To-One override. As a result, those consumers receive all matching messages, regardless of whether or not the producer sends the message using the Deliver-To-One feature.
To enable the Deliver-To-One feature for non‑durable consumers using Direct Transport, use SolAdmin or the CLI to disable the DTO Override property (
deliver-to-one-override) for the Connection Factory.
It is also possible to set delivery priorities for each consumer. Priority levels range from 1 (the highest priority) to 4 (the lowest priority). When a Deliver-To-One message is published, the client with the highest priority receives the message. If multiple clients have the same priority, the client is chosen in a round-robin fashion. The priority is specified by the
subscriber-local-priority or subscriber-network-priority JNDI Connection Factory properties.
Network DTO priority subscription flags are currently ignored by the Solace JNDI. They are reserved for future development.
Deliver-To-One is not supported for durable consumers or non-durable consumers using Guaranteed transport. These consumers always connect using a Deliver-To-One override.