简体   繁体   English

Web应用程序,集群的tomcat和mongoDB-如何实现持久性队列

[英]Web application, clustered tomcats and mongoDB - how to achieve a persistance queue

We are building a small web application that will run on a cluster of 3 tomcats with a load balancer, the web app is based on the spring framework with spring data module to for the mongodb. 我们正在构建一个小型Web应用程序,该Web应用程序将在带有负载均衡器的3个tomcat群集上运行,该Web应用程序基于带有用于mongodb的spring数据模块的spring框架。

Our goal is to have a queue with persistancy (will retain data on cluster failure \\ server shut down etc). 我们的目标是拥有一个具有持久性的队列(将在集群故障\\服务器关闭等情况下保留数据)。

This queue must be emptied if its size > 0. 如果队列的大小> 0,则必须将其清空。

We would like that some process will try to empty this queue if the queue size>0 如果队列大小> 0,我们希望某些进程尝试清空此队列

here are some things to consider: 这里有一些要考虑的事情:

1) in order to remove an element from the queue , some amount of logic is needed. 1)为了从队列中删除一个元素,需要一定数量的逻辑。 2) it is very likely that after some amount of logic is done for a specific queue-element, the resultion will be NOT to remove the element from the queue. 2)很可能在对特定队列元素进行了一定数量的逻辑处理后,结果是不会从队列中删除该元素。 (to be later on retried) 3) we are using a cluster of tomcats, we must retain a concurrency mechanism for things not to go wrong. (稍后重试)3)我们使用的是tomcat集群,我们必须保留一种并发机制,以确保事情不会出错。 (no locking is supported by mongodb) (mongodb不支持锁定)

any ideas whats the easiest way to achieve this? 有什么想法是实现这一目标的最简单方法?

thanks! 谢谢!

Use ActiveMQ between Tomcat and Mongo. 在Tomcat和Mongo之间使用ActiveMQ。 Have one queue for requests. 有一个请求队列。 Get the value from the queue and process it. 从队列中获取值并进行处理。 If retry is needed, use AMQs retry mechanism and add the object to the same queue. 如果需要重试,请使用AMQs重试机制并将对象添加到同一队列中。

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

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