Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Service Broker / January 2007

Tip: Looking for answers? Try searching our database.

Is Service Broker the way to go?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael MacGregor - 11 Jan 2007 20:25 GMT
Hi Everyone,

This is a high level question.

We are going to be reviewing our current system architecture and a little
bird, a good friend of mine who is one of the most knowledgable SQL Server
MVPs I know, told me I should take a look at Service Broker. Well I have
some other questions about it that he felt would be best if I asked in this
newsgroup, so here goes.

Our current system consists of a central database and a lot of remote
locations. Due to the nature of the business, the remote locations are
actually the masters, and data cannot be saved in the central DB without the
remote being committed. However, it is possible to commit data at the remote
that isn't necessarily committed centrally - this is one of the problem
areas.

The central database should still contain data from all locations, and is
also the data source for the website, regardless of which location is
involved.

Sorry if this is kinda vague but for obvious reasons I can't divulge too
much about the actual business.

Currently there are a number of issues with the system as it exists right
now, and please note I am new to this and my job is to get the issues
resolved. First of all, almost all of the tables have PKs that are GUIDs,
which I would like to eliminate. The reasoning behind this is due to the
master status of the remote locations coupled with the fact that the central
database stores all data, so the PK must be unique across the entire system.
When data is committed at the remotes, that PK value must still be unique,
regardless of whether or not the data is successfully committed in the
central database, hence the use of GUIDs, in an attempt to achieve
system-wide uniqueness. Of course the problem is now that GUIDs are
non-sequential and with them also being PKs there are an awful lot of page
splits going on and re-organization of indexes. I want to get rid of GUIDs
and replace them with a sequential ID, quite possibly IDENTITY values.

The other problem with committing at the remote first, is that currently
MSMQ is being used to transmit the transaction to the central database, and
it is, at best, unreliable. Data gets lost.

Now in the other direction, a transaction that begins at the central
database cannot be committed until the transaction at the remote has been
successfully committed. Distributed transactions are NOT being used for
this. Instead the application open two parallel connections, and begins the
transaction on the central database but does not commit it until it receives
confirmation from the other connection, to the remote, that the data was
committed successfully. Then, and only then, in the transaction in the
central database committed. This causes various issues, including deadlocks,
as the locks on the tables and indexes are being held until the remote
transaction is committed. Due to the location and connection type for some
remotes, the remote transactions can take a very long time to commit.

The other part of this is whether or not the technology is able to use
Service Broker. Right now the central database is 2005 Enterprise, but the
remotes are all 2000 Personal Edition. Obviously the remotes would have to
be updated to 2005 and I presume the equivalent to PE would be 2005 Express.
Would there be any issues with using Service Broker with Express?

Any other suggestions, hints, advice, etc. would be greatly appreciated.

Thanks.

Michael MacGregor
Database Architect
Roger Wolter[MSFT] - 11 Jan 2007 22:15 GMT
I hesitate to answer this one first because I'm hoping some less biased
opinions will be expressed.  My answer is "of course Service Broker is the
right answer - now what was the question again?"

The guid primary key issue is probably best left out of the discussion
because it will lead to a huge thread that has nothing to do with Service
Broker.  My only comments would be to consider either sequential guids
(added to 2005 to improve replication performance) or a two-part key with an
identity column and a source system column (hostname or just a number).  If
you have a limited number of sites and a limited number of inserts at each
site you could consider using identity seeds but that gets hard to manage.

If I understand your requirements correctly this is how I would approach it
(let me know if I'm off base).

On the remote servers when you do an operation in the SQL Express database
that needs to be replicated to the central server, put the operation into a
Service Broker message (probably an XML document) and SEND it.  The SEND
should be part of the transaction so the message isn't sent until the
transaction commits.  The message will be stored in the database until a
connection can be established to the central server and then it will be
sent.  Because the message is in the same database as the data, it won't get
lost unless the database is lost (at which point the message really doesn't
matter anymore).  If the network is down, Service Broker will keep trying
until the message is sent.  On the central server database, implement an
activated stored procedure that receives messages and writes them to the
database.  Since everything happens in the database, this is pretty
bulletproof also.  Activation will automagically manage the background
processes to handle the messages.

To do an update from the central server side use the same logic as you did
on the remote side except just send the message without doing the database
update.  An activated procedure in the remote database would receive these
messages, update the database, and send the message back to the central
server in a single transaction.  When the message gets to the central
server, the same service that received the other messages will receive this
one and do the update the same as if it was initiated from a remote server.
This asynchronous update means that the application doing the update in the
central database won't see the results in the central database until the
message have made the round trip but on the other hand, transactional
messaging will ensure that the update is done eventually and the application
on the central database won't hang if the remote database isn't available.

Let me know if this doesn't make sense or if you need more information.
Feel free to contact me directly (take the "online" out of my return
address).

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

> Hi Everyone,
>
[quoted text clipped - 64 lines]
> Michael MacGregor
> Database Architect
Michael MacGregor - 12 Jan 2007 17:36 GMT
I am honoured.

Thank you for your reply, it was most informative.

Sounds like this would be the way to go. Now I shall have to go out and buy
your book, but I've heard that it is very good.

MTM
Roger Wolter[MSFT] - 12 Jan 2007 17:53 GMT
I usually recommend buying two copies - one for work and one for home.

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

>I am honoured.
>
[quoted text clipped - 4 lines]
>
> MTM
Michael MacGregor - 12 Jan 2007 18:53 GMT
Now there's an idea. lol

MTM
Remus Rusanu [MSFT] - 12 Jan 2007 19:30 GMT
What's wrong with reading in buss, train or airplane? Don't you agree each
deserves a copy? I'm sure you do :)

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

HTH,
~ Remus Rusanu

SQL Service Broker
http://msdn2.microsoft.com/en-us/library/ms166043(en-US,SQL.90).aspx

>I usually recommend buying two copies - one for work and one for home.
>
[quoted text clipped - 6 lines]
>>
>> MTM
Simon Sabin - 18 Jan 2007 20:04 GMT
Hello Michael,

The other option is to use replication.

You could replicate from remote back to the central server.
Setting the replication as an updating subscriber (peer to peer may also
work) will mean that updates at the central DB can be either applied directly
to the subscriber via a DTC transaction or using queued updates.

Depending on the size of the DB will dictate where the complexity lies. SB
will requrie changing all your app logic for saving data, replication won't.
Replication is more difficult to manage and would require Workgroup edition
of SQL 2005

Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons

> Hi Everyone,
>
[quoted text clipped - 66 lines]
> Michael MacGregor
> Database Architect
Michael MacGregor - 18 Jan 2007 20:18 GMT
Hi Simon,

Yes I've explored replication as a possible solution, and in fact, it was
previously attempted. However I don't think it was configured and setup
correctly previously and did not work as expected (I wasn't here at that
point). Anyway I ended up in a lengthy discussion about Replicaiton with
Hilary Cotter but based on what I know about replication and what I've heard
about Service Broker, I am leaning towards Service Broker to meet our
requirements.

Thanks.

MTM
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.