首页 > 解决方案 > Spring Cloud Stream 配置问题

问题描述

我正在尝试升级旧版应用程序的版本。我正在尝试使用 spring-cloud-stream 开发 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);
            }
        };
    }
}

标签: springspring-cloudspring-cloud-streamspring-cloud-config

解决方案



推荐阅读