From 9573090e8cfc7344eee07c785b8a142675cbefe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=82=85=E5=93=A5?= <184172133@qq.com> Date: Sun, 8 Oct 2023 16:49:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=82=85=E5=93=A5=EF=BC=8Cfeat?= =?UTF-8?q?=EF=BC=9AGuava=20=E5=B7=A5=E5=85=B7=E5=AF=B9=E8=B1=A1=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bugstack/xfg/dev/tech/test/ApiTest.java | 19 +++++++++++++++++++ .../infrastructure/listener/XxxListener.java | 9 +++++++++ 2 files changed, 28 insertions(+) create mode 100644 xfg-dev-tech-infrastructure/src/main/java/cn/bugstack/xfg/dev/tech/infrastructure/listener/XxxListener.java diff --git a/xfg-dev-tech-app/src/test/java/cn/bugstack/xfg/dev/tech/test/ApiTest.java b/xfg-dev-tech-app/src/test/java/cn/bugstack/xfg/dev/tech/test/ApiTest.java index 95e82d0..2f7f6e5 100644 --- a/xfg-dev-tech-app/src/test/java/cn/bugstack/xfg/dev/tech/test/ApiTest.java +++ b/xfg-dev-tech-app/src/test/java/cn/bugstack/xfg/dev/tech/test/ApiTest.java @@ -8,6 +8,8 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.Weigher; import com.google.common.collect.ImmutableList; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; import com.google.common.hash.BloomFilter; import com.google.common.hash.Funnels; import com.google.common.net.InternetDomainName; @@ -176,4 +178,21 @@ public class ApiTest { log.info("测试结果 - isOverridable:{}", invokable.isOverridable()); } + @Test + public void test_eventbus() { + EventBus eventBus = new EventBus(); + eventBus.register(new Listener()); + // 可以由其他服务推送消息,之后就可以在监听中收到了 + eventBus.post("消息总线,订单号:100001"); + } + + static class Listener { + @Subscribe + public void handleEvent(String orderId) { + log.info("测试结果:{}", orderId); + } + } + } + + diff --git a/xfg-dev-tech-infrastructure/src/main/java/cn/bugstack/xfg/dev/tech/infrastructure/listener/XxxListener.java b/xfg-dev-tech-infrastructure/src/main/java/cn/bugstack/xfg/dev/tech/infrastructure/listener/XxxListener.java new file mode 100644 index 0000000..34d4381 --- /dev/null +++ b/xfg-dev-tech-infrastructure/src/main/java/cn/bugstack/xfg/dev/tech/infrastructure/listener/XxxListener.java @@ -0,0 +1,9 @@ +package cn.bugstack.xfg.dev.tech.infrastructure.listener; + +/** + * @author Fuzhengwei bugstack.cn @小傅哥 + * @description + * @create 2023-10-08 16:10 + */ +public class XxxListener { +} -- GitLab