August 2, 2010 at 12:34 am
Hiii every one,
the code below is taken from
http://www.sqlservercentral.com/articles/Development/anintroductiontotheservicebroker/1957/
Executing code below in one database give expected results but not in other databse....no error but I get a blank Receive queue table instead of Receive queue showing 'Hello World' in message column.....FYI service broker is enabled on both the databases and set trustworthy is also on.
[Obviously there is no proble with code]
CREATE MESSAGE TYPE HelloMessage
VALIDATION = NONE
GO
-- Once the message type has been created, we need to create a contract
-- that specifies who can send what types of messages
CREATE CONTRACT HelloContract
(HelloMessage SENT BY INITIATOR)
GO
-- The communication is between two endpoints. Thus, we need two queues to
-- hold messages
CREATE QUEUE SenderQueue
CREATE QUEUE ReceiverQueue
GO
-- Create the required services and bind them to be above created queues
CREATE SERVICE Sender
ON QUEUE SenderQueue
CREATE SERVICE Receiver
ON QUEUE ReceiverQueue (HelloContract)
GO
-- At this point, we can begin the conversation between the two services by
-- sending messages
DECLARE @conversationHandle UNIQUEIDENTIFIER
DECLARE @message NVARCHAR(100)
BEGIN
BEGIN TRANSACTION;
BEGIN DIALOG @conversationHandle
FROM SERVICE Sender
TO SERVICE 'Receiver'
ON CONTRACT HelloContract
-- Send a message on the conversation
SET @message = N'Hello, World';
SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE HelloMessage (@message)
COMMIT TRANSACTION
END
GO
-- Receive a message from the queue
RECEIVE CONVERT(NVARCHAR(max), message_body) AS message
FROM ReceiverQueue
-- Cleanup
DROP SERVICE Sender
DROP SERVICE Receiver
DROP QUEUE SenderQueue
DROP QUEUE ReceiverQueue
DROP CONTRACT HelloContract
DROP MESSAGE TYPE HelloMessage
GO
thanks in advance....
August 2, 2010 at 12:45 am
- Can you find messages (that you can relate to your setup) in the sqlserver errorlog file ?
- did you run the troubleshooting scripts ? http://www.sqlservercentral.com/scripts/Maintenance+and+Management/31867/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
August 2, 2010 at 12:56 am
thanks for the quick reply....
if i run
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'some_password';
in my database and then execute the code its working
my bad....should have checked the prereqs for service broker......nyways thank you so much....
August 2, 2010 at 3:20 pm
Make sure you have created a database master key in the database. Whether you are using encryption or not that has to be created.
LOL for some reason I missed you last post.
The probability of survival is inversely proportional to the angle of arrival.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply