Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««1234»»»

An Introduction to the Service Broker Expand / Collapse
Author
Message
Posted Tuesday, August 30, 2005 11:43 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 28, 2005 7:13 AM
Points: 18, Visits: 1

First off, I apologize for not responding to this thread earlier. I did not have an account at the forum and recently created one.

Not sure if any commercial scale applications have yet been developed using Service Broker, but I remember Roger Walter writing a few articles about the same and also delivering a few webcasts.

Here is one article about some use cases: http://msdn.microsoft.com/sql/archive/default.aspx?pull=/library/en-us/dnsql90/html/sql2k5_SrvBrk.asp



HTH,
Srinivas Sampath
Blog: http://blogs.sqlxml.org/srinivassampath
Post #215390
Posted Tuesday, August 30, 2005 11:46 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 28, 2005 7:13 AM
Points: 18, Visits: 1

First off, I apologize for not responding to this thread earlier. I did not have an account at the forum and recently created one.

Service Broker messages are always sent to a service. Each service is associated with a queue and each queue can have an activation procedure that wakes up when messages arrive at the queue. You can also specify the maximum number of activation procedures that Service Broker can instantiate for the queue.



HTH,
Srinivas Sampath
Blog: http://blogs.sqlxml.org/srinivassampath
Post #215392
Posted Tuesday, August 30, 2005 11:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 28, 2005 7:13 AM
Points: 18, Visits: 1

First off, I apologize for not responding to this thread earlier. I did not have an account at the forum and recently created one.

Service Broker can basically be used to achieve asynchronous semantics in the database. In your case, the application tier receives messages from an external source and if you are not using transactional messaging in MSMQ, the performance of SSB and MSMQ is comparable. Also, in your case, if the application tier is load-balanced, you will have multiple Q's doing the job. I would not recommend replacing this solution with SSB because, if you need to do some pre-processing of the Q before executing the SP, then you cannot do it. Also, by using MSMQ in this case, you can have other applications that can also drain the Q.

SSB is largely for writing reliable, asynchronous, message oriented database applications.



HTH,
Srinivas Sampath
Blog: http://blogs.sqlxml.org/srinivassampath
Post #215400
Posted Wednesday, August 31, 2005 1:24 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, October 15, 2012 1:12 AM
Points: 185, Visits: 43
I test this script on JuneCTP2005 SQL2005, but
RECEIVE CONVERT(NVARCHAR(max), message_body) AS message
FROM ReceiverQueue

or
SELECT CONVERT(NVARCHAR(max), message_body) AS message
FROM ReceiverQueue

gives nothing
Must the Sender and Receiver be different computers ?
Post #215557
Posted Thursday, September 1, 2005 11:57 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 28, 2005 7:13 AM
Points: 18, Visits: 1

First check if the ReceiverQueue itself has any message. If not, check the sys.transmission_queue to see if any errors are logged. One other post that I made had a user with a similar problem and the sys.transmission_queue had a message indicating an error about a missing database master key. If you see a similar error, you can solve it using the method that I've outlined in: http://blogs.sqlxml.org/srinivassampath/archive/2005/06/19/3457.aspx



HTH,
Srinivas Sampath
Blog: http://blogs.sqlxml.org/srinivassampath
Post #216412
Posted Saturday, October 1, 2005 5:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, October 1, 2005 4:59 AM
Points: 1, Visits: 1

Hello, great article, compact & clear. On my june CTP version, it didn't seem to work without the following change (maybe update the article ? )

DECLARE @conversationHandle UNIQUEIDENTIFIER
DECLARE @message NVARCHAR(100)

BEGIN
  BEGIN TRANSACTION;
  BEGIN DIALOG @conversationHandle
        FROM SERVICE Sender
        TO SERVICE 'Receiver'
        ON CONTRACT HelloContract WITH ENCRYPTION=OFF, LIFETIME= 600;
  -- Send a message on the conversation
  SET @message = N'Hello, World';
  SEND  ON CONVERSATION @conversationHandle
        MESSAGE TYPE HelloMessage (@message)
  COMMIT TRANSACTION
END
GO

regards,

steph

 

Post #225346
Posted Monday, October 17, 2005 8:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 12, 2007 9:59 AM
Points: 2, Visits: 1

Hello

I too am having problems getting this sample to work.

I created a db called TestDb.

I then pasted the sample service broker code (with your ENCRYPTION change)

into the mgmt studio. I modified the USE statement at the top.

There is never anything in the ReceiverQueue.

Everyone tries their sample code against the AdventureWorks db. I suspect that

db has some property set that we are not being told about.

Could you try the sample code after you create a new database.

 

Thanks.




Post #229357
Posted Friday, March 10, 2006 7:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 21, 2011 8:43 AM
Points: 3, Visits: 33
Hi,

I tried your example but could not able to receive the message back. Pelase guide what I am doing wrong. Receive statement does not return any data back.

USE master;
GO

CREATE ENDPOINT BrokerEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 4037 )
FOR SERVICE_BROKER ( AUTHENTICATION = WINDOWS ) ;

Go
Use MySampleDB
Go
Create MESSAGE TYPE HelloMessage VALIDATION = None
GO
Create CONTRACT HelloContract ( HelloMessage SENT BY INITIATOR )
GO
Create Queue SenderQueue
GO
Create QUEUE ReceiverQueue
GO
Create Service Sender ON QUEUE SenderQueue
GO
Create Service Receiver ON QUEUE ReceiverQueue (HelloContract)
GO
DECLARE @conversationHandle UNIQUEIDENTIFIER
DECLARE @message nvarchar(100)
Begin
Begin Transaction;
Begin Dialog @conversationHandle
From Service Sender
TO Service 'Receiver'
ON CONTRACT HelloContract
Set @Message = N'Hellow, World';
Send ON Conversation @conversationHandle MESSAGE TYPE HelloMessage (@message)
Commit Transaction
End
Go

Receive Convert(Nvarchar(max),message_body) as message
From ReceiverQueue
GO
Select * from SenderQueue
Select * from ReceiverQueue
Select * from dbo.ServiceBrokerQueue
Post #264840
Posted Sunday, March 19, 2006 1:28 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, June 9, 2014 6:13 PM
Points: 80, Visits: 331

hbatra -

I have just developed a C# app that does exactly what you explained (ie, writes from an MSMQ queue to a SQL Server table).  Do you mind sharing how you run this app?  As a scheduled task, a job in SQL Server, a service???  Just wondering.  Thanks.

Steve

Post #266776
Posted Monday, April 17, 2006 11:43 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 16, 2012 7:08 AM
Points: 3, Visits: 124

Nice article, but I'm not getting anything when I execute posted code.

Does anybody have an idea why?

Thanks




Post #273606
« Prev Topic | Next Topic »

Add to briefcase ««1234»»»

Permissions Expand / Collapse