Monday, February 20, 2012

Newb question

If I am using Ado.Net from a .Net Class library hosted outside SqlServer to do Sends and Receives do I have to use anything else other than queues? The reason I am asking is because I already have an abstraction layer for a couple of our queueing systems and I was hoping to put SSB in there as well but the abstraction layers' primitive is the Queue not Conversation/Dialog/Service, etc.

Thanks

CostasWhile you could build a layer that exposes just queues, you will soon discover that it will not be possible to expose all the richness of Service Broker (i.e. conversations, conversation group locking, etc) in that manner. But if you need to keep the existing interface in order to port your app over, you could certainly build a layer based on Queues like you describe.|||Rushi, thanks. The reason I asked is that almost all the examples I've seen use conversation where using the queues. Can you point me to an example where I can do send & receive solely with queues?

Thanks

Costas|||OK, I am getting the idea that I cannot just "send" a message to a queue. I think I have to create a queue and a service to go with it. Now, if my client needs to "send" on a queue, can I fake it with 1 stored procedure that takes the service name as a parameter?

Does this look reasonable?

create message type
[http://www.myblobcom/msg/BlobMsg]
validation = NONE;

create contract [http://www.myblobcom.com/contract/SaveBlob/v1.0]
(
[http://www.myblobcom.com/msg/BlobMsg] sent by initiator
);

create queue [Blob Queue];

create service [BlobSvc]
on queue [Blob Queue]
(
[http://www.myblobcom.com/contract/SaveBlob/v1.0]
);

CREATE PROCEDURE SaveBlob (

@.service varchar(36),

@.queue varchar(36),

@.payload VARBINARY(MAX))
AS BEGIN
declare @.dh uniqueidentifier;

-- HERE IS WHERE I HAVE MY CONCEPTUAL PROBLEM
-- HOW DO I BEGIN A DIALOG WITH A STORED PROCEDURE
-- CALLED BY AN EXTERNAL ADO.NET CLIENT?
-- begin dialog @.dh
-- from service [Inventory Client]
-- to service 'Inventory'
on contract [http://www.myblobcom.com/contract/SaveBlob/v1.0]
with encryption=off;

send on conversation @.dh message type [http://www.myblobcom/msg/BlobMsg] (@.payload );

end

Thanks

Costas|||Hi, can someone tell me if I am on the right track?

Thanks

Costas|||

Uncomment the begin dialog lines. Use the @.service parameter as the to service in that statement. That will allow you to begin a dialog and send a message in your stored proc. This proc can be called from ADO.Net.

|||

Rushi, thanks, I am not sure what to do with the [from service]. What's the from service set to when you're called from an extarnal ADO.NET client?

Cheers

Costas

|||

Dialog conversations are persistent sessions between two services -- the initiator and the target service. When beginning a dialog, you must specify the initiator service in the from argument and the target service in the to argument. Even if you use dialogs for one-way messaging, you still need a 'from' service where errors could be sent back as reponses. Each service has its own queue which serves as a backing store where messages are delivered until the service receives them.

Refer to Books Online to understand more about Service Broker architecture. You could also get a copy of Roger Wolter's book on Service Broker.

|||Rushi, thanks, I think that's where my ability to comprehend the service broker external call breaks down. All samples, articles, etc discuss it from the point of view of internal services talking to each other through dialogs which is not what I want to do or is it? Are you implying that my "from" service is really just a placeholder in my case just so that the dialog can take place? So, I'd call the stored proc from ado.net which will send a message in the queue from what I can call the "externalactivationservice" and the message will be sent to my handle blob service.

I am going to give it a shot, thanks

Costas

No comments:

Post a Comment