Share via


Service Broker Message Forwarding

Service Broker message forwarding allows an instance of SQL Server to accept messages from outside the instance and send those messages to a different instance.

An administrator can use message forwarding to:

  • Provide connectivity between servers in different trust domains
  • Simplify administration by creating a single centralized instance that holds the routing information for a domain
  • Distribute work among several instances

When forwarding is enabled, the routing table in msdb.sys.routes determines whether a message that arrives from another instance is forwarded. If the address for the matching route is not LOCAL, SQL Server forwards the message to the address specified. Otherwise, the message is delivered locally.

Each Service Broker message contains a maximum lifetime and a count of the number of times that the message has been forwarded. When an instance forwards the message, that instance increases the count in the message. If the message exceeds the maximum lifetime, the forwarding instance discards the message. This strategy helps avoid problems in situations where a routing loop may exist.

Forwarding and Reliable Delivery

An instance that forwards a message does not acknowledge the message to the sender. Only the final destination acknowledges the message. If the sender does not receive an acknowledgement from the destination after a period of time, the sender retries the message.

An instance that performs message forwarding does not need to store forwarded messages. Instead, SQL Server holds messages to be forwarded in memory. The amount of memory available for message forwarding is specified as part of the Service Broker endpoint configuration. This strategy allows efficient, stateless message forwarding. In the event that an instance that performs message forwarding fails, no messages are lost. Each message is always maintained at the sender until the final destination acknowledges the message, as described in Service Broker Communication Protocols.

The management view sys.dm_broker_forwarded_messages contains information about messages that are currently in the process of being forwarded by the instance. An instance does not persist messages in the process of being forwarded; these messages exist only in memory. The instance that sent the message and the instance that receives the message persist the messages. The sending instance does not remove the message until the receiving instance acknowledges receipt of the message.

Security and Forwarding

Service Broker message forwarding does not require a forwarding instance to decrypt the forwarded message. Therefore, only the databases that participate in the conversation must have dialog security configured.

However, because transport security applies to the connections between SQL Server instances each SQL Server instance must have transport security correctly configured for the instances that it communicates with directly. For example, if Instance A and Instance B communicate through a forwarding instance, then both Instance A and Instance B must have transport security correctly configured for the forwarding instance. Because the instances do not exchange messages directly, the instances should not have transport security configured to communicate with each other.

See Also

Concepts

Service Broker Routing and Networking
Service Broker Endpoints
Service Broker Dialog Security
Service Broker Transport Security

Other Resources

CREATE ENDPOINT (Transact-SQL)
ALTER ENDPOINT (Transact-SQL)
sys.dm_broker_forwarded_messages
sys.routes (Transact-SQL)
sys.transmission_queue (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance