管理 JVM 外代理池和通信

发布于 2024-09-11 01:20:03 字数 278 浏览 5 评论 0原文

我需要从我的应用程序管理一组代理。所有这些都是用 Java 编写的,但代理需要在自己的 JVM 中运行。我编写了一个概念证明,它启动子进程并使用 stdout/stdin 发送命令和保持活动信息。我还打开一个套接字连接进行数据传输。

我想一些连接池库应该能够帮助管理代理。

代理和主进程之间的通信怎么样?使用 TCP 和 XML 消息 (JAXB) 并不像我希望的那样可靠或方便。对于更好的图书馆有什么建议可以在这里提供帮助吗?

我自己可以很好地写出我需要的内容,但我确信其他人已经做得更好了。

I need to managed a pool of agents from my application. All are written in Java but the agents need to run in their own JVM. I wrote a proof of concept that starts the subprocesses and uses the stdout/stdin to send commands and keep-alive information. I also open a socket connection for data transfer.

I guess that some connection pooling libraries should be able to help in the management of the agents.

What about the communication between the agents and the main process ? Using TCP with XML messages (JAXB) is not really as reliable or convenient as I would like. Any suggestion for a better library to assist here ?

I could very well write what I need myself but I'm sure other people have done that way better already.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半暖夏伤 2024-09-18 01:20:03

对于消息传递,可以尝试类似 ZeroMQ 的东西,它是一个消息传递工具,并且具有用于进程之间通信的本地传输,然后您只能在进程之间序列化对象。

另一种选择是回到传统的 rmi,这可能是最简单的。

For messaging could try something like ZeroMQ, it's a messaging tool and has local transports for communicationg between processes, then you could just serialised objects between the process.

The alternative is to go back to traditionally rmi, probably the simplest.

捶死心动 2024-09-18 01:20:03

实际上,我发现了两种对我开发此程序有很大帮助的方法:

  1. WebSockets。我使用了简单的套接字,但随后我需要重新发明信号来检查谁在发送以及已完成发送。我使用了基于线条的方法,但它真的很难看。 WebSocket 提供基于消息的通信,这很棒。
  2. 榛树。这是一个“分布式系统”,提供了一些很棒的东西,比如分布式执行器(我安排一条消息在应用程序服务器中发送,并让任何可用的 jvm 外代理以原子方式处理它)、共享和线程安全的哈希图(以保持我见过的许多类似工具要么是本机代码(比如 ZeroMQ 顺便说一句),要么是带有每个 CPU 许可证等。 Hazelcast 是社区版,可以捆绑到我的应用程序中。

实际上,我已经开始使用 vert.x 来处理基于 websocket 的通信,并意识到它本身就是使用 hazelcast。

I've actually found two ways that would have been of great help when I developed this:

  1. WebSockets. I used simple sockets but then I needed to reinvent signaling to check who's sending and done sending things. I used a line-based approach but it's really ugly. WebSockets offer the message-based communication and that's great.
  2. Hazelcast. This is a "distributed system" and offers great things like distributed executors (I schedule a message to be sent in the app server and let any available out-of-jvm agent handle it, atomically), shared and thread safe hashmaps (to keep track of who is running) etc. Many of the similar tools I had seen were either in native code (like ZeroMQ btw) or with per-CPU licenses and such. Hazelcast is community edition and can be bundled into my apps.

Actually, I had started using vert.x to handle websocket-based communication and realized it was itself using hazelcast.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文