在 Java EE 应用程序中通过消息队列对临时数据进行后台处理
我正在构建一个 Java EE Web 应用程序,它还有一个 JAX-RS API,以便其他网站上的插件可以向它发送数据,将其视为一个分析服务器,它从各个客户端站点接收数据并拥有自己的管理界面人们可以在其中查看统计数据。
客户端发送的数据当前保存在数据库的临时表中;之后应该进一步处理,并保存到保存统计数据的真实表中。
之后我应该如何实现该数据的后台处理?我应该自己创建线程,还是应该使用消息队列系统(我已经研究过 RabbitMQ,它似乎很有前途,但我不确定它是否适合嵌入到 Java EE 应用程序中)
另外,我应该保存我当前数据库中的临时数据(来自用户的一大块信息,作为 JSON/XML 字符串),或者您认为保存在另一个临时数据库中更合适,例如我再次听说过像 Redis、mongodb 这样的 nosql 数据等等,但是无法决定自己是否适合做这个。
最后,如果我应该使用消息队列,请求应该由消息队列处理,还是由 JAX-RS 处理?我对 JAX-RS 的担忧是它的性能可能不如队列,正如我所说,我并不真正需要 API,我只是想获取单个 base-64 编码的字符串(包含各种统计信息)来自客户网站。
I am building a Java EE web application, which also has a JAX-RS API so that plugins at other web sites can send data to it, think of it like an analytics server which receives data from various client sites and has its own admin interface where one can view the stats.
The data that the clients send is currently saved in a temporary table in the database; and is supposed to be further processed afterwards, and saved into the real table holding the statistic data.
How should I implement the background processing of that data afterwards? Should I create threads myself, or should I use a message queue system (I have looked at RabbitMQ and it seems promising, however I'm not sure if it is appropriate for embedding in a Java EE application)
Also, should I be saving the temporary data (one chunk of information from the user, as a JSON/XML string) in my current database, or would you think that saving in another temporary database is more appropriate, for example I have again heard of nosql datas like Redis, mongodb etc., however cannot decide whether they are suitable for this.
Finally, if I should use a message queue, should the requests be handled by the message queue, or again JAX-RS? My concern with JAX-RS would be that it may not be as performant as queues and as I said, I don't really need an API, I just want to get a single base-64 encoded string (that contains various statistical info) from the client web sites.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有很多问题 :) 我将尝试按顺序回答:
Lots of questions here :) I'll try to answer in order: