简体   繁体   English

Vert.x - 限制所有集群中的单个实例 Verticle

[英]Vert.x - limit single instance verticle in all cluster

I have a Vert.x application with several verticls to interact with different buses and dbs (mongo, redis, rabbit, kafka and such)我有一个Vert.x应用程序,其中有几个 Verticl 可以与不同的总线和数据库(mongo、 redis 、rabbit、kafka 等)交互

among those there is a verticle dedicated for communication with external api (very old) which allow for one persistent connection and from a single (pre defined) source其中有一个verticle专用于与外部api(非常旧)通信,它允许一个持久连接和来自单个(预定义)源

I'm deploying mutli instances of vertx with the same code (auto-scale) and make them act as a cluster, using hazelcast as a cluster manager我正在使用相同的代码(自动缩放)部署多个 vertx 实例,并使它们充当集群,使用hazelcast作为集群管理器

what is the best practice for limiting the creation of the external-api verticle to only single instance, I looked at:external-api verticle的创建限制为仅单个实例的最佳实践是什么,我查看了:

  • SharedData.Lock() - but I'll need to wrap it with an async spinning lock logic SharedData.Lock() - 但我需要用异步旋转锁逻辑包装它
  • High Availability - great for termination and auto-scaling but doesn't force activity of a single verticle High Availability - 非常适合终止和自动缩放,但不强制单个 Verticle 的活动
  • worker verticle - to create 1 worker verticle in each instance worker verticle - 在每个实例中创建 1 个 worker verticle

I could use a mix of all the above and create the desired functionality, but I seems some what complex...我可以混合使用上述所有功能并创建所需的功能,但我似乎有些复杂......

should I separate my verticle to a different server or there is some simpler solution I haven't thought of yet?我应该将我的 Verticle 分离到不同的服务器还是有一些我还没有想到的更简单的解决方案?

You don't need single verticle, leave that verticle to be just stateless and apply your connections in Proxy service - after you can register that service as HttpEndpoint, Evenbus, Message or JDBC service types and you will have single point of comminication with db or external http source.您不需要单个顶点,将该顶点保持为无状态并在代理服务中应用您的连接 - 在您可以将该服务注册为 HttpEndpoint、Evenbus、Message 或 JDBC 服务类型之后,您将与 db 或外部 http 源。

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

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