惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
U
Unit 42
D
Docker
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
V
Visual Studio Blog
I
InfoQ
Google DeepMind News
Google DeepMind News
小众软件
小众软件
L
LangChain Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
J
Java Code Geeks
罗磊的独立博客

博客园 - 荣锋亮

just-git 纯js 的git 实现 阿里开源的UnifiedModel agno agentos interfaces 简单说明 agno agentos ag-ui 协议 agno agentos 暴露a2a 协议 agno gateway模式 agno 多agent 框架集成能力 agno agentos 简单说明 agno workflow 模式简单说明 agno team agent 简单说明 agno remote agent 简单说明 agno agent 使用 agno agent 平台 sshpiper 简单试用 sshpiper ssh 的反向代理服务 context-propagation spring reactor 的上下文传递包 nginx 发布1.31.2 了 reductstore 的一些部署模式 reductstore 数据写入模式 reductstore bridge 方便reductstore数据bridge 扩展 reductstore zenoh 集成 zenoh 1.9.x 一些新特性 ladybugdb嵌入式图数据库 BlockHound 检测 reactor阻塞调用的agent reductstore 高性能面向机器人以及IOT场景的存储以及流数据基石 zerofs 一些新功能 java nats request-many 支持的一些模式 context7 面向llm 以及ai代码编辑器的依赖包更新平台 NATS Agents Protocol nats 团队提出的agent 通信协议 metamcp mcp聚合&调度工具
java nats RequestMany
荣锋亮 · 2026-06-09 · via 博客园 - 荣锋亮

nats js sdk 很早就支持RequestMany的特性,java 版实际是不支持的,但是nats 的背后公司基于jnats 包装了orbit.java 实现了类似功能

参考玩法

  • 依赖
 <dependency>
            <groupId>io.synadia</groupId>
            <artifactId>request-many</artifactId>
            <version>0.1.1</version>
 </dependency>
  • 使用
Options options = new Options.Builder()
                .server("nats://localhost:4222")
                .inboxPrefix("_inbox.dalong")
                .build();

        try (Connection nc = Nats.connect(options)) {

            // Use the standard sentinel builder shortcut
            RequestMany rm = RequestMany.standardSentinel(nc);
            System.out.println(rm);

            // start a responder simulator.
            Dispatcher dispatcher = nc.createDispatcher(m -> {
                for (int x = 0; x < 10; x++) {
                    System.out.println(m.getReplyTo());
                    nc.publish(m.getReplyTo(), ("R" + x + "-" + new String(m.getData())).getBytes());
                }
                nc.publish(m.getReplyTo(), null);
            });
            dispatcher.subscribe("dalong");
            rm.request("dalong", "hello".getBytes(), (message) -> {
                System.out.println("Received: " + new String(message.toString()));
                return true;
                //  return list.add(message);
            });

        }

说明

以上是简单说明(callback 模式),实际还支持其他模式的(max requests,timeout 等)

参考资料

https://github.com/synadia-io/orbit.java/tree/main/request-many

https://github.com/synadia-ai/synadia-agents/tree/main/client-sdk

https://github.com/nats-io/nats.js/blob/main/core/src/nats.ts#L190