[英]ActiveMQ gives: “Could not connect to broker URL: tcp://localhost:61616” after around 10 000 messages
[英]Spring Boot and ActiveMQ: Ignores broker-url and uses default localhost:61616
我正在使用Spring Boot和ActiveMQ。 在application.properties中,我像這樣設置activemq的網址:
spring.activemq.broker-url=vm://localhost?broker.persistent=false
如您所見,我正在使用嵌入式代理(在pom中添加了依賴性)。 這是我的應用程序類:
@SpringBootApplication
@EntityScan(
basePackageClasses = {ServiceApplication.class, Jsr310JpaConverters.class}
)
@EnableAutoConfiguration
@ServletComponentScan
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
}
這些是pom中與activemq相關的依賴關系:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.14.5</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.14.5</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.14.5</version>
</dependency>
我只有一個application.properties,沒有不同的配置文件。
但是,當我運行該應用程序時,會收到以下日志:
[ActiveMQ Task-1] o.a.a.t.failover.FailoverTransport : Failed to connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry.
它試圖連接到tcp:// localhost:61616,即使這不是我定義的url。
我嘗試刪除@EnableAutoConfiguration,但仍然是相同的問題。
我該如何解決?
您的ActiveMQ客戶端不知道spring.activemq.broker-url
因為此屬性用於配置spring-boot-starter-activemq。如果沒有此啟動器,則無需配置該屬性。
我建議您閱讀以下資源,以更好地了解如何在項目中設置spring-boot-starter-activemq:
希望能幫助到你!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.