Solved

Using service broker in sql server 2005

Posted on 2013-01-13
8
394 Views
Last Modified: 2013-03-12
Hi Experts,

I am new to service broker and using event/subscriber process I need to do below task.

For example:
Whenever a change is made to  a table (test) in test_db ,we need to insert records into  two tables (demo,sample) of another database demo_db using event/subscriber process
I was told to create stored procedures for eventsubscribe,eventunsubscribe etc to achieve this.

Can anyone share the code(sql scripts) for the above task?
0
Comment
Question by:ksd123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 10

Expert Comment

by:Matt Bowler
ID: 38772832
There is actually a bit of setup involved with service broker 2005. One good place to start is with the templated queries in SSMS:

http://msdn.microsoft.com/en-us/library/ms179334(v=sql.90).aspx
0
 
LVL 12

Assisted Solution

by:Saurabh Bhadauria
Saurabh Bhadauria earned 500 total points
ID: 38773241
I guess your databases are residing on single server. you can configure service broker a databases like in below link....

http://www.mssqltips.com/sqlservertip/1836/sql-server-service-broker-example-on-how-to-configure-send-and-receive-messages/

You can create trigger on you first table to feed records in initiators queue..

Do some research and let me know if you required further guidance...

Thanks,
Saurabh
0
 

Author Comment

by:ksd123
ID: 38775282
Hi Saurabh,

Could you please elaborate me how many triggers/stored procedures message types/contracts/queues/services required  on both source and destination database's needed to achieve above task?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

Expert Comment

by:Eugene Z
ID: 38781968
<Whenever a change is made to  a table (test) in test_db >


try to use triggers:
Audit table data changes in SQL Server 2005
http://codeinet.blogspot.com/2006/09/audit-table-data-changes-in-sql-server.html
0
 

Author Comment

by:ksd123
ID: 38798588
Hi ,

I have created trigger on the first table  and suggest me on the next steps
(how many Messages,queues,services,SP's) needed to achieve above task
0
 
LVL 12

Accepted Solution

by:
Saurabh Bhadauria earned 500 total points
ID: 38799852
look at the below link....to undrstand the architecture of Service broker...

http://www.codeproject.com/Articles/11795/Introducing-Distributed-Messaging-using-Service-Br

You gonna required at least one message type of each initiator and on target...Same with the Queue and Service .. It's also obvious in first link...
like
-Create Service for the Initiator.
CREATE SERVICE [//SBTest/SBSample/SBInitiatorService]
ON QUEUE SBInitiatorQueue;
--Create Service for the Target.
CREATE SERVICE [//SBTest/SBSample/SBTargetService]
ON QUEUE SBTargetQueue
([//SBTest/SBSample/SBContract]);



On SP : once message is reached on target from initiator , a Sp is required at target to handle message. Similarly if you want to send a message acknowledgement to initiator from target then you gonna required a SP at initiator end as well

Thanks,
Saurabh
0
 

Author Closing Comment

by:ksd123
ID: 38977349
Thank you
0

Featured Post

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question