SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Service Broker (2005)
 send message in one DB
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ali.dashtebozorgi
Starting Member

3 Posts

Posted - 12/29/2008 :  09:00:53  Show Profile  Reply with Quote
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

Slovenia
11751 Posts

Posted - 12/29/2008 :  09:13:56  Show Profile  Visit spirit1's Homepage  Reply with Quote
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!

Edited by - spirit1 on 12/29/2008 09:14:12
Go to Top of Page

ali.dashtebozorgi
Starting Member

3 Posts

Posted - 12/30/2008 :  04:02:17  Show Profile  Reply with Quote
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

India
1 Posts

Posted - 10/04/2011 :  02:30:17  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000