簡體   English   中英

無法使用Spring-Cloud-Stream創建RabbitMQ Exchange

[英]RabbitMQ Exchange not getting created using Spring-Cloud-Stream

我是Java Spring Cloud的新手。 我正在嘗試使用RabbitMQ將消息發布到交易所。 但是一旦運行Java應用程序,就看不到正在創建任何Exchange。 我也沒有任何錯誤。 我想念什么?

我嘗試將磁盤可用限制設置為200MB,最初將其設置為50MB,但仍然沒有發現任何變化。

下面是我的控制器類的代碼片段:

public class AppointmentController {

private static final Logger 
   logger=LoggerFactory.getLogger(AppointmentController.class);
    @Autowired
    AppointmentSender sender;

    @PostMapping("/appointment-management-service/appointments")
    public void bookAppointment(@RequestBody AppointmentEvent 
              appointmentEvent) 
    {
       logger.info("Appointment request received {}",appointmentEvent);
       appointmentEvent.setStatus(AppointmentStatus.INITIATED);
       boolean isSent = sender.send(appointmentEvent);
       logger.info("Appointment booking initiated {}",isSent);

     }

}

以下是我的Message Sender類的代碼段::

@EnableBinding(Source.class)
public class AppointmentSender {

@Autowired
private Source source;

public boolean send(AppointmentEvent appointmentEvent) {
      return this.source.output().
      send(MessageBuilder.withPayload(appointmentEvent).build());
}

}

以下是application.properties文件

spring.application.name=appointment-management-service
server.port=8000
spring.jpa.show-sql=true
spring.h2.console.enabled=true
spring.rabbitmq.host=127.0.0.1
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.rabbitmq.broker-url=tcp://127.0.0.1:5672
spring.rabbitmq.virtual-host= /
spring.cloud.stream.bindings.output.destination=appointments-exchange

下面是pom.xml ::

 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.microservices</groupId>
<artifactId>appointmentmanagementsystem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>appointmentmanagementsystem</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
     <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
    </dependency>
   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>
     <dependency>
        <groupId>com.rabbitmq</groupId>
        <artifactId>amqp-client</artifactId>
        <version>5.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-test-support</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<dependencyManagement>
      <dependencies>
          <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                 <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>


<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

</project>

沒有創建名稱為“ appointments-exchange”的交易所。

我只是將您的屬性復制到一個新的Boot項目中,並且工作正常。

在此處輸入圖片說明

您的訪客用戶是否具有管理員權限?

嘗試啟用DEBUG日志記錄以查看是否有任何線索。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM