При использовании шины springcloud пользовательское сообщение создается и отправляется через rabbitmq
, но после отправки оно не переходит на rabbitmq
.Когда вы пытаетесь набрать call /actuator/bus-refresh
, вы можете увидеть сообщения шины, отправленные со страницы консоли 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>
о @RemoteApplicationEventScan
, я кодирую все в одном пакете, поэтому я долженбыть в состоянии отсканировать до TestEvent
.Я также попытался указать basepackage
.
@SpringBootApplication
@RemoteApplicationEventScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@RestController
@RequestMapping("test")
public class TestController {
@Autowired
private ApplicationContext context;
@RequestMapping("test")
public String test() {
final TestEvent testEvent = new TestEvent(this, context.getId(), null,"test");
context.publishEvent(testEvent);
return "success";
}
}
@Data
public class TestEvent extends RemoteApplicationEvent {
private String action;
public TestEvent(Object source, String originService, String destinationService, String action) {
super(source, originService, destinationService);
this.action = action;
}
}
Когда я позвонил http://localhost:8080/actuator/bus-refresh
, я вижу информацию в rabbitmq
.
{" 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
, я не звоню.