Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / Service Broker / August 2006

Tip: Looking for answers? Try searching our database.

Service Broker doesn't produce what I expect [Please Read]

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bishoy George - 04 Aug 2006 19:28 GMT
Hi,

I made a simple service broker code that is:

-- step 1: Enable Broker

use master

alter database AdventureWorks

set enable_broker

go

-- step 2: prepare

use AdventureWorks

go

create schema CustomerService

go

create schema EmailService

go

-- step 3: Message Type

create message type [//AdventureWorks/Sales/CustomerDetails]

validation = well_formed_xml

go

-- step 4: Contract

create contract [//AdventureWorks/Sales/SendCustomerDetails]

(

[//AdventureWorks/Sales/CustomerDetails] sent by initiator

)

go

-- step 5: Queue

create queue CustomerService.NewCustomerQueue

go

create queue EmailService.NewCustomerEmailQueue

go

-- step 6: Service

create service [//AdventureWorks/Sales/CustomerService]

on queue CustomerService.NewCustomerQueue

go

create service [//AdventureWorks/Sales/EmailService]

on queue EmailService.NewCustomerEmailQueue

(

[//AdventureWorks/Sales/SendCustomerDetails]

)

go

-- step 7:

create procedure CustomerService.proc_SendMessage

(

@firstName nvarchar(50)

,@lastName nvarchar(50)

,@emailAddress nvarchar(200)

)

as

-- sending a message

declare @message nvarchar(max)

set @message = nchar(0xFEFF)

+ '<Customer>'

+ '<CustomerName>' + @firstName + ' ' + @lastName + '</CustomerName>'

+ '<EmailAddress>' + @emailAddress + '</EmailAddress>'

+ '</Customer>'

declare @conversationHandle uniqueidentifier

begin dialog conversation @conversationHandle

from service [//AdventureWorks/Sales/CustomerService]

to service '//AdventureWorks/Sales/EmailService'

on contract [//AdventureWorks/Sales/SendCustomerDetails]

;send on conversation @conversationHandle

message type [//AdventureWorks/Sales/CustomerDetails]

(

@message

)

go

create procedure CustomerService.proc_ReceiveMessage

as

-- receiving a message

declare @conversationHandle uniqueidentifier, @messageTypeName nvarchar(256)

;receive top(1)

@conversationHandle = conversation_handle

,@messageTypeName = message_type_name

from CustomerService.NewCustomerQueue

if @@rowcount = 0

begin

print 'No further message found in CustomerService.NewCustomerQueue'

end

go

exec CustomerService.proc_SendMessage 'Bishoy','George','bishoy@bishoy.com'

exec CustomerService.proc_ReceiveMessage

--------------------------------------------------------------------------------------------------------------------------

Now the problem is:

when I execute the 2 procedures I receive:

(0 row(s) affected)
No further message found in CustomerService.NewCustomerQueue

Why doesn't the broker send the message?

Is there any needed preparing should I have done first?

Thank you and best regards.
Dan Sullivan - 04 Aug 2006 20:16 GMT
In this case there are three place you can look to see what happened, the sending queue, receiving queue and the sys.transmission_queue. One of those will probably have a message indicating what happened.

use AdventureWorks
SELECT * FROM CustomerService.NewCustomerQueue
SELECT * FROM EmailService.NewCustomerEmailQueue
SELECT * FROM sys.transmission_queue

I don't think the AdventureWorks database has a master key, which is needed in almost all cases by Service Broker. Try doing a

use AdventureWorks
CREATE MASTER PASSWORD ENCRYPTION BY PASSWORD = 'mya%%%Passw0rd'

Dan
Bishoy George - 06 Aug 2006 10:03 GMT
Thank you very much Dan.

You helped me very much.

Sorry for my late reply.

Thank you again.

Bishoy

> In this case there are three place you can look to see what happened, the
> sending queue, receiving queue and the sys.transmission_queue. One of
[quoted text clipped - 12 lines]
>
> Dan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.