c# - WCF Subscriber to Azure SB with multiple operations -


i trying make wcf service both publishes messages topic , subscribes topic. idea have service expose endpoints managing customer (i.e. createcustomer, editcustomer, deletecustomer, etc). want publish message topic after completes each operation (i.e. oncustomercreated, oncustomerchanged, oncustomerdeleted, etc.)

for example, client application hit editcustomer message on service. publish oncustomerchanged message customer object provided. service (the same 1 customer hit) have contract takes oncustomerchanged , updates database.

my question is, have make separate subscription on topic each message type (i.e. oncustomerchangedsubscription, oncustomerdeletedsubscription, etc.) can route messages of different types correct endpoint?

if case, need bunch of single-method contracts configure wcf endpoints properly:

i.e:

 <service name="site.services.business.managers.customermanager">    <!-- endpoint clients hit -->     <endpoint address="" binding="basichttpbinding" contract="site.services.business.contracts.icustomermanager" />    <!-- endpoint publishes messages-->     <endpoint address="sb://test-site.servicebus.windows.net/managers/customermanager"                binding="nettcprelaybinding"                contract="site.services.business.contracts.icustomermanager"                behaviorconfiguration="sbtokenprovider" />     <!-- 1 endpoint each message type (this cumbersome , contract have 1 method on it) -->     <endpoint address="sb://test-site.servicebus.windows.net/managers/customermanager"                   binding="netmessagingbinding"                   listenuri="sb://test-site.servicebus.windows.net/managers/customermanager/subscriptions/oncustomerdeleted"                   behaviorconfiguration ="sbtokenprovider"                   contract="site.services.business.contracts.customermanager.ioncustomerdeleted" />     <endpoint address="sb://test-site.servicebus.windows.net/managers/customermanager"                   binding="netmessagingbinding"                   listenuri="sb://test-site.servicebus.windows.net/managers/customermanager/subscriptions/oncustomercreated"                   behaviorconfiguration ="sbtokenprovider"                   contract="site.services.business.contracts.customermanager.ioncustomercreated" /> …etc    </service> 

an alternative create single subscriber (allmessages), having 1 contract handlemessage(brokeredmessage message) operation, , determine inside method method call on service. doesn't seem doing right thing there though either. taking in messages , determining handler inside service.

what looking way have a service implements 3 contracts, icustomerpublisher (already have this), icustomermanager (exposed on http clients), , icustomersubscriber.

icustomersubscriber like:

[servicecontract] public interface icustomersubscriber {     [operationcontract(isoneway = true)]     void oncustomercreated(icustomermessage message);      [operationcontract(isoneway = true)]     void oncustomerdeleted(icustomermessage message);      [operationcontract(isoneway = true)]     void oncustomerchanged(icustomermessage message); } 

and able call:

publisher.publish<oncustomerchanged>(new customerchangedmessage(customer)); 

and have oncustomerchanged method receive message.

any appreciated.

first: yes, if service has per-request activation, subscriptionclient won't chance run except while service responds external request, , have created , torn down every time. feasible way keep subscriptionclient running change activation singleton.

but think better approach pull subscriptionclient out of service entirely , have run on own. if want run on-prem, in windows service or console app; in cloud, webjob or worker role. again, don't see why onmessage method needs wcf operation.

second: if there's 1 subscription, each message can received , completed 1 client. if multiple clients need copy of each message, each client needs own subscription. subscriptions can share same filter conditions, or no conditions.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -