我正在尝试升级遗留应用程序的版本。我正在尝试用springcloudstream开发amqp的一部分。我不能在rabbitmq队列中侦听,如果没有交换(我不能改变这种方式),如何实现一个只针对一个队列的侦听器??
这是我的app-properties.yml
cloud:
function:
definition: inputCollector
stream:
default:
contentType: application/json
declareExchange: false
binders:
rabbitmq:
type: rabbit
bindings:
inputCollector-in-0:
queueNameGroupOnly : true
group : collector_result.Collections
binder: rabbitmq
还有我的密码
@Configuration
@AllArgsConstructor
public class AnyHandler {
private static final Logger LOG = LoggerFactory.getLogger(InputCollectorHandler.class);
private final CollectorService collectorService;
@Bean
public Consumer<Event> inputCollector() {
return user -> {
LOG.info("event received", user);
try {
anyService.handleCollectorResponse(user);
} catch (Exception e) {
LOG.error("Error processing message: " + user);
}
};
}
}
1条答案
按热度按时间ejk8hzay1#
declareExchange: false
一定在下面...rabbit.defaults...
或者...rabbit.bindings.....consumer.
https://docs.spring.io/spring-cloud-stream-binder-rabbit/docs/3.1.1/reference/html/spring-cloud-stream-binder-rabbit.html#_rabbitmq_consumer_properties.