Sunday, March 11, 2012

Alter service <SVC1> (Add contract <CONTRACT>) does not really work, need help

Hi,

Sure you can run

Create Service SVC1 ON QUEUE QUEUE1 (CONTRACT1);

alter service SVC1 (add contract CONTRACT2);

But You can only send message using contract1, when you try to send msg using contract2, it always say can not find CONTRACT "contract2".

The following query shows the contract is there.

select s.*,c.* from sys.service_contract_usages U

inner join sys.services S on S.service_id = U.service_id

inner join sys.service_contracts C on U.service_contract_id=C.service_contract_id

where S.name='SVC1'

declare @.lMsg xml

declare @.ConversationHandle uniqueidentifier

set @.lMsg = '<test>testing</test>'

Begin Transaction

Begin Dialog @.ConversationHandle

From Service SVC1

To Service 'SVC2'

On Contract contract1

WITH Encryption=off;

SEND

ON CONVERSATION @.ConversationHandle

Message Type [type1]

Commit

The above works, but the following will not work.

declare @.lMsg xml

declare @.ConversationHandle uniqueidentifier

set @.lMsg = '<test>testing</test>'

Begin Transaction

Begin Dialog @.ConversationHandle

From Service SVC1

To Service 'SVC2'

On Contract CONTRACT2

WITH Encryption=off;

SEND

ON CONVERSATION @.ConversationHandle

Message Type [type2]

(@.lMsg)

Commit

Any idea ?

Thanks!

The service contract bindings of the initiator service (SVC1) are irelevant. Is the target service (SVC2) that has to be bound to a specific contract. Try altering SVC2.|||

I mean everywhere SVC2. it is a typo when I posted the msg, my bad.

But still the alter service is still not working, any idea ?

|||

Works fine for me:

Code Snippet

use tempdb

go

create message type mt1 validation = none;

create message type mt2 validation = none;

create contract sc1 (mt1 sent by any);

create contract sc2 (mt2 sent by any);

create queue q1;

create queue q2;

create service svc1 on queue q1;

create service svc2 on queue q2 ([sc1]);

alter service svc2 (add contract [sc2]);

go

declare @.h uniqueidentifier;

begin dialog conversation @.h

from service svc1

to service 'svc2', 'current database'

on contract [sc2]

with encryption = off;

send on conversation @.h message type [mt2];

waitfor (receive message_type_name, service_contract_name, * from q2);

go

message_type_name service_contract_name status priority queuing_order conversation_group_id conversation_handle message_sequence_number service_name service_id service_contract_name service_contract_id message_type_name message_type_id validation message_body

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

mt2 sc2 1 0 0 DDCD3F76-9C50-DC11-B57C-00188B111155 DECD3F76-9C50-DC11-B57C-00188B111155 0 svc2 65537 sc2 65537 mt2 65537 N NULL

(1 row(s) affected)

|||

I am using distributed environment, It did not work when I tried.

I will re-test it, and update you.

|||It works, My bad, because I have different contract names, which caused the failure. Sorry for the late response.

No comments:

Post a Comment