How to create custom WCF binding which effectively reverses the communication?

倖福魔咒の 提交于 2019-12-11 14:24:46

问题


I have Server sending requests to Agents. When the agent has something to say it sends replies to Server. All is clear and simple.

Now, I wish to cancel the Server-to-Agent communication. In effect Agents will poll Server and get in reply if there is work to do.

It seems to me that all of this should be encapsulated in a custom WCF binding, which would contain the following items at least:

  • A reference to the effective WCF binding used to poll Server on the reversed Agent-to-Server channel.
  • Polling interval

From the Server perspective, the channel supports only one way interfaces. The server would use it as any one way interface - fire and forget. The custom binding would store the request details and supply them to the correct Agent as soon as it polls the Server.

I am not that experienced in writing custom WCF bindings. So, my question is to the experienced folks over there - does it make sense to implement the custom binding I am talking about? If so, I would really like to get some pointers.

Thanks.

EDIT1:

Agent is not a client of a server. The current logic is that Server initiates communication to the Agent, which makes it a client of Agent. The need to reverse the communication channel does not come from a functional change in their roles. Rather it is a result of firewall constraints on the Agent - it may ban any inbound communication. I wish to preserve the server side logic as much as possible, meaning the server continues to initiate the communication, but under the hood it is the agent which constantly polls for work.


回答1:


I think you're looking for Pub/Sub Model here. Please check following link, it's an example, http://tomasz.janczuk.org/2009/07/pubsub-sample-using-http-polling-duplex.html

HTH Amit



来源:https://stackoverflow.com/questions/4890284/how-to-create-custom-wcf-binding-which-effectively-reverses-the-communication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!