655
Chapter 25: Asynchronous Messaging with Service Broker
25
END ;
END; -- Process all messages in conversation group.
-- Commit the RECEIVE and the END conversation statement.
COMMIT TRANSACTION ;
END ; -- Process all conversation groups.
Service Broker can handle complex message groups, such as multiple line items of an order
that may not appear consecutively in the queue due to other messages being received
simultaneously. The conversation group can be used to select out the related messages.
What’s New in Service Broker for SQL Server 2012?
SQL Server 2012 adds several enhancements to Service Broker functionality and informa-
tional columns. The following sections describe each of these enhancements in more detail.
Message Multicast
Messages can now be sent to multiple target services using a single SEND statement. The
ability to multicast the same message is possible by initiating multiple conversation han-
dles and including them as a comma separated list after the ON CONVERSATON clause.
The caveat with message multicast is that if the SEND statement encounters an error with
one or more of the conversations, the whole statement fails, and no messages are stored in
the transmission queue or are received in any target service queue.
This means that all target services included in a message multicast must be in a valid state
for the SEND statement to be successful.
AlwaysOn Support
AlwaysOn Availability Groups is the new high availability and disaster recovery solu-
tion introduced in SQL Server 2012. This new feature is discussed in detail in Chapter 27,
“Database Mirroring.”
Service Broker is supported in the AlwaysOn Availability Group but several require-
ments need to be met to successfully receive asynchronous messages. For a service in an
Availability Group to receive remote messages, there are four main requirements as follows:
- Create and confi gure a listener in the Availability Group.
- Create and confi gure a Service Broker endpoint.
c25.indd 655c25.indd 655 7/31/2012 9:21:38 AM7/31/2012 9:21:38 AM
http://www.it-ebooks.info