使用现有组件阻止 apache Camel 中的消费者
我想使用 Apache Camel JDBC 组件来读取 Oracle 表。我希望 Camel 在分布式环境中运行,以满足可用性问题。但是,我正在读取的表类似于队列,因此我只想在任何给定时间有一个读取器,这样我就可以避免锁定问题(在 Oracle 中很混乱)。
如果读者宕机了,我希望另一个读者能够接替。
您将如何使用开箱即用的 Camel 组件来完成此任务?是否可以?
I would like to use the Apache Camel JDBC component to read an Oracle table. I want Camel to run in a distributed environment to meet availability concerns. However, the table I am reading is similar to a queue, so I only want to have a single reader at any given time so I can avoid locking issues (messy in Oracle).
If the reader goes down, I want another reader to take over.
How would you accomplish this using the out-of-the-box Camel components? Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于您的部署架构。例如,如果您以主/从配置(用于 HA)在 Servicemix(或 ActiveMQ)上部署 Camel 应用程序,那么在给定时间只有一个消费者处于活动状态……
但是,如果您需要多个运行(集群化)可扩展性),那么(默认情况下)它们将竞争/重复从表中读取,除非您编写自己的锁定逻辑。
使用 Hazelcast 分布式锁定 可以轻松实现这一点。有一个camel-hazelcast组件,但它不支持lock API。一旦您配置您的应用以参与 Hazelcast 集群,那么只需使用锁定 API您需要为给定对象同步的任何代码...
It depends on your deployment architecture. For example, if you deploy your Camel apps on Servicemix (or ActiveMQ) in a master/slave configuration (for HA), then only one consumer will be active at a given time...
But, if you need multiple running (clustered for scalability), then (by default) they will compete/duplicate reads from the table unless you write your own locking logic.
This is easy using Hazelcast Distributed Locking. There is a camel-hazelcast component, but it doesn't support the lock API. Once you configure your apps to participate in a Hazelcast cluster, then just just the lock API around any code that you need to synchronize for a given object...