[英]Pooling messages before sending them to ActiveMQ
The requirement is to send form data produced by website visitors over JMS (ActiveMQ most probably) from Tomcat. 要求是通过JMS(最有可能是ActiveMQ)从Tomcat发送网站访问者生成的表单数据。 There are two competing ideas - one would utilize an intermediary store and a thread pool to send to the queue (and attempt resend if posting to JMS fails for some reason), and the other is to just try sending the payload directly over JMS from the thread that handles the visitors' post request - and fail the request if the JMS posting fails for some reason. 有两种相互竞争的想法-一种是利用中介存储和线程池发送到队列(如果由于某种原因而发布到JMS失败,则尝试重新发送),另一种就是尝试直接从JMS通过JMS发送有效负载。处理访问者发布请求的线程-如果JMS发布由于某种原因失败,则请求失败。
The second option seems better to me, as I think it is an overkill to add an intermediary store in front of a message queue - the message queue itself should be the intermediary store. 第二种选择对我来说似乎更好,因为我认为在消息队列前面添加中间存储是一个过大的选择-消息队列本身应该是中间存储。 Does that sound right? 听起来对吗?
What? 什么? Wait - A MQ Broker IS an intermediary (persistent) store to cope with downtime at the receiver side that can handle resend and what not. 等待-MQ Broker是一个中间存储(持久性),用于应对接收方的停机时间,该时间可以处理重发,而不能处理重发。 Non the less, you are somewhat right. 非少,你是正确的。 You don't want to miss that order just because your (remote) broker is down. 您不希望仅仅因为您的(远程)经纪人失灵而错过订单。 A resilient solution to that problem is to setup a local, possibly embedded ActiveMQ broker, then make a "network of brokers" connection to the remote broker. 针对该问题的一种有弹性的解决方案是设置本地(可能是嵌入式的)ActiveMQ代理,然后与远程代理建立“代理网络”连接。 You can be sure that the local broker is up along with your webapp, and it will handle retransmission to the remote broker, if it happends to be offline for the moment. 您可以确定本地代理和您的Web应用程序都已启动,并且如果当前恰好处于脱机状态,它将处理向远程代理的重新传输。
I would, however, advice against implementing a simple in memory buffer to hold data until it can be posted to the broker. 但是,我建议不要实现一个简单的内存缓冲区来保存数据,直到将其发布到代理为止。
Let's take a scenario (I'm just making up a purpose of the form): 让我们来看一个场景(我只是在构成表单的目的):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.