简体   繁体   English

如何处理来自RabitMQ服务器应用程序的客户端连接

[英]How to handle clients connections from RabitMQ server application

I'm trying to implement an application server just like a chat server using rabbitMq. 我正在尝试实现一个应用服务器,就像使用RabbitMq的聊天服务器一样。

Clients connect directly to the rabbit server. 客户端直接连接到Rabbit服务器。 the application server should be able to know which clients have been connected and when a client disconnects an event should be fired in the application server. 应用服务器应该能够知道连接了哪些客户端,客户端何时断开连接,应该在应用服务器中触发一个事件。

Is it possible to implement this kind of functionality with Rabbitmq? 可以用Rabbitmq实现这种功能吗?

Does Rabbitmq have any kind of event dispatching for connection events?(not for clients but for my application server) Rabbitmq是否对连接事件有任何类型的事件分派?(不是针对客户端,而是针对我的应用服务器)

I'm using official C# client for Rabbitmq. 我正在为Rabbitmq使用官方C#客户端。

As @Lutz Horn already said, you can use the event exchange plugin to emit events related to connections, channels and much more. 正如@Lutz Horn所说的那样,您可以使用event exchange插件来发出与连接,通道等有关的事件。

Reference: https://www.rabbitmq.com/event-exchange.html 参考: https : //www.rabbitmq.com/event-exchange.html
GitHub: https://github.com/rabbitmq/rabbitmq-event-exchange GitHub: https : //github.com/rabbitmq/rabbitmq-event-exchange

You have to create a queue, so that the event exchange routes these events to this queue. 您必须创建一个队列,以便事件交换将这些事件路由到该队列。 And have a consumer that listens to this queue. 并有一个消费者在听这个队列。 I have added a link to the one that I am using. 我添加了一个链接到我正在使用的链接。

Code: https://gist.github.com/sathishbabu96/35821a6b1e90daa76d3dd76bef084788 代码: https//gist.github.com/sathishbabu96/35821a6b1e90daa76d3dd76bef084788

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM