3
在我的Spring Boot應用程序中,我配置了嵌入式Apache ActiveMQ。Spring Boot嵌入式ActiveMQ持久消息
@Configuration
@EnableJms
public class ActiveMQConfig {
@Bean
public Queue queue() {
return new ActiveMQQueue("import.decisions.queue");
}
}
爲了送我用下面的代碼中的消息:
@Autowired
private JmsMessagingTemplate jmsMessagingTemplate;
@Autowired
private Queue queue;
this.jmsMessagingTemplate.convertAndSend(this.queue, message);
現在我使用內存中的ActiveMQ,這是我application.properties
:
#ActiveMQ
spring.activemq.in-memory=true
spring.activemq.pool.enabled=false
spring.activemq.packages.trust-all=true
因爲我不不想丟失已經入隊的消息,例如在應用程序重新啓動期間,我需要配置我的Embedded ActiveMQ來保存數據。
請問您能展示如何使用Spring Boot配置完成嗎?
謝謝您的回答:如果你願意,你可以將其定義覆蓋
。我已將約1000條消息添加到隊列中。然後在執行過程中,我終止了我的應用程序,然後再次啓動它。成功開始後沒有任何反應。消費者不會消費之前入隊的消息。另外,爲了用重寫的代理服務測試你的方法,我在應用程序類路徑中找不到'KahaDBPersistenceAdapter'類。現在,我只在我的Maven'pom.xml'中添加了'spring-boot-starter-activemq',以便啓動並運行ActiveMQ。還應該添加哪些其他工件? – alexanoid
對不起,我忘了mvn的依賴關係,我已經更新了我的回答 –
謝謝,我已經加入了activemq-kahadb-store,現在這個方法開始工作了! – alexanoid