简体   繁体   English

用于群组广播的JMS架构

[英]JMS architecture for group broadcasting

I want to build a broadcasting system. 我想建立一个广播系统。 It consists of several groups. 它由几个组组成。 Each group has one User who can broadcast a message to the other members of the same group. 每个组都有一个用户,可以向同一组的其他成员广播消息。 What is the appropriate JMS architecture for this kind of system? 这种系统合适的JMS体系结构是什么?

Should I use a topic with durable subscription? 我应该使用具有长期订阅的主题吗? I don't know much about pub/sub messaging style, can topic have multiple subscription? 我对发布/订阅消息风格不太了解,主题可以有多个订阅吗? If so, then each subscription represents a group in the broadcasting system. 如果是这样,则每个订阅代表广播系统中的一个组。 If not, should I use a queue whereas each message has a header specifying the group and then use a JMS selector to filter the message so that each member receive only messages from groups he's in? 如果不是,我是否应该使用队列,而每条消息都有一个标头指定该组,然后使用JMS选择器过滤该消息,以便每个成员仅接收来自其所在组的消息?

Also, I am thinking of persisting the messages after consumption. 另外,我正在考虑在消费后保留消息。 I decided to make each message to expire after one hour, and each member should check the database for every message he misses. 我决定让每条消息在一个小时后过期,并且每个成员都应检查数据库以查找他错过的每条消息。 But, how can I fire an action upon message expiration? 但是,如何在消息到期时触发操作?

Topics can be used... Topics can have multiple subscribers. 可以使用主题...主题可以有多个订阅者。 Each group can use a different topic. 每个小组可以使用不同的主题。 The user can send message to that topic and all the subscribers would receive it. 用户可以向该主题发送消息,所有订阅者都可以接收。

The durable subscribers are required only if the subscribers can go offline for sometime and the messages for the subscriber shouldn't be lost. 仅当订户可以脱机一段时间并且不丢失该订户的消息时,才需要持久订户。

Queue doesn't suite well in one-to-many scenarios. 队列不适用于一对多场景。 But if you have a pre-defined set of receivers you can use a queue for each one of them and route messages to that. 但是,如果您有一组预定义的接收器,则可以为每个接收器使用一个队列并将消息路由到该接收器。 But this is a overhead to route the messages to the receiver's queue. 但这是将消息路由到接收者队列的开销。 JMS selector idea you have suggested would work but for a queue only one client can receive a message. 您建议的JMS选择器想法可行,但对于队列,只有一个客户端可以接收消息。 In topics it distributed to all the clients interested in that topic. 在主题中,它分发给对该主题感兴趣的所有客户。

Normally one would persist data to database and not the message itself. 通常,将数据持久化到数据库而不是消息本身。 So you can persist to database and then create the message for delivery. 因此,您可以坚持到数据库,然后创建要传递的消息。

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

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