简体   繁体   English

Apache骆驼浏览队列而无需轮询

[英]Apache camel browse queue without polling it

I need to log my database with events on my ActiveMQ. 我需要使用ActiveMQ上的事件记录数据库。 With logging I mean messages can't be consumed. 通过日志记录,我的意思是无法使用消息。

Is the folowwing thing possible 下列事情可能吗

public class QueueRouteBuilder extends RouteBuilder {
@Override
public void configure(){
 from("browse:activemq:KBC)
.process(new QueueProcessor());
}
}

That camel route is event driven. 骆驼路线是事件驱动的。 Ie it has to somehow poll events of that queue to know whats been dealt with. 即,它必须以某种方式轮询该队列的事件以知道处理了什么。

I would, instead, go for copies to a queue used for logging. 相反,我会将副本复制到用于日志记录的队列中。 This can be done in two ways with ActiveMQ. 使用ActiveMQ可以通过两种方式完成此操作。

  1. Mirrored queues . 镜像队列 That is - every queue has a mirror with all messages copied to it. 也就是说-每个队列都有一个镜像,其中所有消息都复制到该镜像中。 You simply read of the mirror to do logging/monitoring. 您只需阅读镜像即可进行日志记录/监视。
  2. Virtual Destinations . 虚拟目的地 You can setup a Composite Queue that forwards the message to multiple queues (one for real usage and one for logging). 您可以设置一个将消息转发到多个队列的复合队列(一个用于实际使用,一个用于记录日志)。 However, this has to be done via config on all involved queues. 但是,这必须通过配置在所有涉及的队列上完成。
  3. To allow easy wire-tapping, you can switch to topics. 为了便于窃听,您可以切换到主题。 It's easy to tap of the messages by simply adding a subscriber. 只需添加订阅者,即可轻松挖掘消息。 If you really need the queue semantics, you can use Virtual Topics which is the best of the two worlds - topics with queues! 如果您确实需要队列语义,则可以使用虚拟主题 ,这是两个世界中最好的-带队列的主题!

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

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