Web应用程序订阅消息队列

发布于 2024-11-27 10:02:20 字数 693 浏览 0 评论 0原文

Web 有 (1) 一个Web 应用程序,用户可以在其中创建一些任务,以及 (2) 处理任务的其他系统(基于 Java 的服务)。

任务取决于日期/时间 - 用户创建任务,将其开始日期设置为例如明天凌晨 1 点,然后他就完成了。 Java 服务明天凌晨 1 点开始处理任务并向应用程序报告处理的当前状态。

我们计划使用 ActiveMQ (a) 通知服务有关新任务的信息,(b) 通知 Web 应用程序有关当前任务状态的信息。 (a)部分没有问题。

我的问题是 - (b) 是个好主意吗? Web 应用程序必须订阅消息队列,以便在有报告当前任务进度的消息时调用它。 Web 应用程序应该处理该信息并将信息存储在数据库中。
我怀疑我们是否应该以这种方式做到这一点,因为如果网络应用程序没有流量,它就会死亡,订阅者也会死亡。所以消息不会被处理。

创建永久连接到队列的.NET 服务是否更好?在 Web 应用程序中订阅的优点是,如果我们需要在 Nhibernate 中使用二级缓存,一切正常。
如果有两个进程(Web 应用程序、新服务)使用 Nhibernate 和二级缓存,这可能会导致问题,因为每个进程都可以操作不同的数据。


报告可以使用普通的 Web 服务完成,但同事报告说,通过 wcf 从 java 到 .net 进行通信并使用证书进行安全通信非常复杂。

Web have (1) a web application where a user creates some tasks and (2) other system (service based on Java) that processes the tasks.

The tasks are date/time dependent - user creates the task, sets its start date to e.g. tomorrow 1am and he is done. The Java service tomorrow at 1am starts processing the task and reports current status of the processing to the application.

We plan to use ActiveMQ for (a) notifying the service about new task, (b) notifying the web app about current task status. The (a) part is with no problem.

My question is - is (b) good idea? Web app has to be subscribed to the message queue so that it is called when there is a message that reports current task progress. The web app should process that and store the info in db.
I'm in doubt that we should do it in such a way, because if there is no traffic to the web app, it dies and so dies the subscriber. So the messages won't be processed.

Is it better to create .NET service that is permanently connected to the queue? The advantage to be subscribed in web app is that in case we would need to use 2nd level cache in Nhibernate, everything works.
If there are two processes (web app, new service) that use Nhibernate and 2nd level cache, this could cause problems because each of them could operate on different data.


The reporting could be done with ordinary web service, but colleagues reported, that it is quite complicated to communicate over wcf from java to .net and use certificate for secure communication.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铁轨上的流浪者 2024-12-04 10:02:20

我们做了类似的事情,并使用消息队列来保存需要在不同网络服务中执行的任务,如果服务死亡,消息队列将继续写入,我们不会写入sql服务器,因为我们使用不同的机器而且这也可能会下降

我们不订阅队列,我们​​只是打开并弹出消息,如果那里有任何消息,基于计时器,我们发现这更可靠,我们可以设置时间

WE do a similar thing,and use the message queue to hold tasks that need doing in differnet services, if the service dies, the message queue continues to be written to, we don't write to a sql server as we use a different machine AND that could also go down

We don't subscribe to the queue, we simply open and pop and messages of if there are any messges on there, based on a timer, we found this more reliable and we could set the time

方圜几里 2024-12-04 10:02:20

我们已经构建了类似的系统,但在我们的案例中,我们的做法略有不同。

  • 我们使用表而不是队列。这使我们能够记录项目何时被处理并通过将状态更改为“未发送”来重新发送
  • 我们还使用计时器服务而不是触发通知来轮询表

通知的问题是如果应该侦听的系统会发生什么情况因为当通知发出时通知就关闭了。

We have built similar systems, in our case we did it slightly differently.

  • We used a table instead of a queue. This allowed us to log when the item was processed and resend by changing the status to "not sent"
  • We also polled the table with a timer service, instead of a trigger notification

The problem with notification is what happens if the system that should be listening for the notification is down when the notification is raised.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文