Solved

Using service broker in sql server 2005

Posted on 2013-01-13
8
397 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 43

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

738 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