Java Springcloud总线自定义消息无法通过rabbitmq发送
使用springcloud总线时,会创建一条自定义消息并通过Java Springcloud总线自定义消息无法通过rabbitmq发送,java,spring-boot,spring-cloud,spring-cloud-stream,spring-rabbit,Java,Spring Boot,Spring Cloud,Spring Cloud Stream,Spring Rabbit,使用springcloud总线时,会创建一条自定义消息并通过rabbitmq发送,但在发送消息后,它不会转到rabbitmq。当您尝试调用/执行器/总线刷新时,您可以看到从rabbitmq的控制台页面发出的总线消息 我试图启动一个微服务来注册一个自定义事件侦听器,但没有收到它。但是,如果发送方自己注册了一个侦听器,他可以接收它,但不能从rabbitmq发送它 <parent> <groupId>org.springframework.boot</g
rabbitmq
发送,但在发送消息后,它不会转到rabbitmq
。当您尝试调用/执行器/总线刷新时,您可以看到从rabbitmq的控制台页面发出的总线消息
我试图启动一个微服务来注册一个自定义事件侦听器,但没有收到它。但是,如果发送方自己注册了一个侦听器,他可以接收它,但不能从rabbitmq
发送它
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
{" type ":" AckRemoteApplicationEvent ", "timestamp" : 1554350325406, "originService" : "application: 0: b3461fbec3536203a7020ff9d24bb11b", "destinationService" : "* *", "id" : "e6b875bd - 2402-494 - f - a870 - 4917324 d2c5c ackId ", "" :" af93075e - 55 d2-41 f8 - ba27 - e3c80cf19eea ", "ackDestinationService" : "* *", "the event" is: "org. Springframework. Cloud. Bus. Event. RefreshRemoteApplicationEvent"}.
当我打电话给http://localhost:8080/actuator/bus-刷新
我可以在rabbitmq
中看到信息
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
{" type ":" AckRemoteApplicationEvent ", "timestamp" : 1554350325406, "originService" : "application: 0: b3461fbec3536203a7020ff9d24bb11b", "destinationService" : "* *", "id" : "e6b875bd - 2402-494 - f - a870 - 4917324 d2c5c ackId ", "" :" af93075e - 55 d2-41 f8 - ba27 - e3c80cf19eea ", "ackDestinationService" : "* *", "the event" is: "org. Springframework. Cloud. Bus. Event. RefreshRemoteApplicationEvent"}.
但是当我调用
http://localhost:8080/test/test
,我不知道。几天前我遇到了同一个问题,结果证明这是因为原始服务
不正确。将context.getId()
作为originService
传递不起作用
简短回答:使用org.springframework.cloud.bus.BusProperties#id
。您可以将BusProperties
注入组件。或者,您可以按照中的说明配置自己的spring云总线id
我不是100%确定这是正确的方法。也许我在文件里遗漏了什么。它只是基于我从org.springframework.cloud.bus.BusAutoConfiguration
方法的源代码中读到的内容
希望它对您有用。几天前我遇到了同一个问题,结果证明这是因为
原始服务
不正确。将context.getId()
作为originService
传递不起作用
简短回答:使用org.springframework.cloud.bus.BusProperties#id
。您可以将BusProperties
注入组件。或者,您可以按照中的说明配置自己的spring云总线id
我不是100%确定这是正确的方法。也许我在文件里遗漏了什么。它只是基于我从org.springframework.cloud.bus.BusAutoConfiguration
方法的源代码中读到的内容
希望对您有用。对不起,我的英语不是很好,请理解,我正在使用翻译,这是我第一次使用stackoverflow。请给我更多的建议对不起,我的英语不是很好,请理解,我正在使用翻译,这是我第一次使用stackoverflow。请给我更多的建议
{" type ":" AckRemoteApplicationEvent ", "timestamp" : 1554350325406, "originService" : "application: 0: b3461fbec3536203a7020ff9d24bb11b", "destinationService" : "* *", "id" : "e6b875bd - 2402-494 - f - a870 - 4917324 d2c5c ackId ", "" :" af93075e - 55 d2-41 f8 - ba27 - e3c80cf19eea ", "ackDestinationService" : "* *", "the event" is: "org. Springframework. Cloud. Bus. Event. RefreshRemoteApplicationEvent"}.