我編寫了簡單的示例來從控制臺讀取文本并將其發(fā)送到rabbitMq服務器:@Configuration@EnableIntegration@IntegrationComponentScanpublic class Config { @Autowired private AmqpTemplate amqpTemplate; @Bean public IntegrationFlow fromConsoleToRabbitFlow() { return IntegrationFlows.from(consoleSource(), c -> c.id("consoleInput") .poller(Pollers.fixedRate(1000)) .autoStartup(true) ).channel("consoleOutputChannel") .handle(Amqp.outboundAdapter(amqpTemplate).routingKey("my_spring_integration_queue")) .get(); } public MessageSource<String> consoleSource() { return CharacterStreamReadingMessageSource.stdin(); }}my_spring_integration_queue它看起來幾乎可以工作的解決方案,但我在rabbitmq管理控制臺中找不到:但我在其他選項卡上找不到與“my_spring_integration_queue”相關的任何內(nèi)容。我在哪里可以找到它?我希望應用程序會創(chuàng)建隊列(如果不存在)。我無法找到發(fā)送到隊列的方法,所以我使用了.routingKey方法。我也嘗試過.exchangeName方法,但它導致:32019-08-27 13:26:15.972 ERROR 16372 --- [ 127.0.0.1:5672] o.s.a.r.c.CachingConnectionFactory : Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'my_spring_integration_queue' in vhost '/', class-id=60, method-id=40)聚苯乙烯隊列選項卡如下所示:
1 回答

阿晨1998
TA貢獻2037條經(jīng)驗 獲得超6個贊
您需要手動添加隊列或使用 aRabbitAdmin
?@Bean
自動為您聲明它 - 管理員將找到所有類型的 beansQueue
并聲明它們。
如果你使用的是 Spring Boot,它會自動為你配置一個管理 bean,所以你只需要Queue
?@Bean
.
添加回答
舉報
0/150
提交
取消