views:

114

answers:

3

What is Service Broker in SQL Server and is it meaningful to enableitin a simple Database, Not in a distributed DB.

please do not close this question, I saw others similar question and non of them answered me.

+3  A: 

SQL Service broker is an extension mechanism that allows you to queue events for asynchronous processing.

there is no intrinsic harm in enabling the broker, if its not used it will just be idle.

It works in both simple and distributed DBs. A simple use case would be a logging queue. We used it at a client to queue xml messages to be processed asynchronously. So we push an xml to a InitatorQueue, and then had a service pull them from the queue, extract some necessary attributes via xpath, and insert them into a persistence table in our database.

Here is a good reference

Nix
+2  A: 

Service Broker is a messaging system built into the SQL server db engine. Here's some articles you might read to see how it works.

Centralized Asynchronous Auditing with Service Broker
Centralized Asynchronous Auditing across Instances and Servers with Service Broker
How to troubleshoot Service Broker problems

Mladen Prajdic
A: 

Service Broker is an asynchronous messenging system. It allows you to send a message to a queue. Then some some worker process picks up the message. There are no guarantees about the order, or when, a message is picked up. But SQL Server does guarantee that message processing happens in a transactional way.

Asynchronous messenging is one of the heaviest architectures out there. You should consider carefully whether the added value is worth the complexity.

Andomar
actually Service Broekr guarantees messages are received in order they are sent in.
Mladen Prajdic
@Mladen Prajdic: That's true for messages in the same conversation, but not generally. For example, say you send a CreateClient message to the ClientCreator, and then a CreateAddress message to the AddressCreator. The second might be processed before the first is finished.
Andomar
Because Service Broker is integrated with Sql Server engine, it doesn't need to use distributed transactions, which actually makes it one of the most lightweight (and therefore well performing) architectures out there.
Pawel Marciniak
@Pawel Marciniak: Asynchronous programming is a heavy architecture. Agree that within asynchronous programming, Service Broker is a relatively lightweight approach
Andomar