Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Service Broker (2005)
 send message in one DB

Author  Topic 

ali.dashtebozorgi
Starting Member

3 Posts

Posted - 2008-12-29 : 09:00:53
hi
i define initiatorservice,targetservice,MAIN_CONTRACT in the same DB and use this code for sending message from initiator to the target

use ali
BEGIN TRY
BEGIN TRANSACTION;
DECLARE @ch UNIQUEIDENTIFIER
DECLARE @msg NVARCHAR(MAX);
BEGIN DIALOG CONVERSATION @ch
FROM SERVICE [initiatorservice]
TO SERVICE 'targetservice'
ON CONTRACT [MAIN_CONTRACT]
WITH ENCRYPTION = OFF;
SET @msg =
'<HelloWorldRequest>
i'm ali
</HelloWorldRequest>';
SEND ON CONVERSATION @ch MESSAGE TYPE [REQUESTMESSAGE]
(
@msg
);
COMMIT;
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
GO

when i run this code it execute correctly .in the other side i use this code to see the recieved message in target_queue

SELECT * FROM QUEUE_target

but there is no recieved message .
what's the problem ?!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-12-29 : 09:13:56
check the sys.transmission_queue to see if your message was sent correctly
also see if this helps:
http://www.sqlteam.com/article/how-to-troubleshoot-service-broker-problems

___________________________________________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

ali.dashtebozorgi
Starting Member

3 Posts

Posted - 2008-12-30 : 04:02:17
yes . my messages was sent correctly .
when i use this T_SQL i'll see them

USE ALI
SELECT * FROM sys.transmission_queue
GO

but i can not receive them with this code !

DECLARE @cg UNIQUEIDENTIFIER
DECLARE @ch UNIQUEIDENTIFIER
DECLARE @messagetypename NVARCHAR(256)
DECLARE @messagebody XML;
BEGIN TRY
BEGIN TRANSACTION;
RECEIVE TOP(1)
@cg = conversation_group_id,
@ch = conversation_handle,
@messagetypename = message_type_name,
@messagebody = CAST(message_body AS XML)
FROM QUEUE_target
PRINT 'Conversation group: ' + CAST(@cg AS NVARCHAR(MAX))
PRINT 'Conversation handle: ' + CAST(@ch AS NVARCHAR(MAX))
PRINT 'Message type: ' + @messagetypename
PRINT 'Message body: ' + CAST(@messagebody AS NVARCHAR(MAX))
COMMIT
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
GO

why ?!
Go to Top of Page

shan1231
Starting Member

1 Post

Posted - 2011-10-04 : 02:30:17
Studentname Sub1 Sub2 Sub3 Marks(sub1)
shankar kannada maths maths 40 70 12
shan kannada maths maths 70 80 12
manju kannada maths maths 70 80 90
delwin kannada maths maths 40 70 12


shankar
Go to Top of Page
   

- Advertisement -