Spring Mono与春季云流
我在尝试使用反应堆的Mono和Spring Cloud Stream时遇到了一个问题,无法真正了解到底发生了什么 假设我有一个这样的听众:Spring Mono与春季云流,spring,spring-cloud-stream,Spring,Spring Cloud Stream,我在尝试使用反应堆的Mono和Spring Cloud Stream时遇到了一个问题,无法真正了解到底发生了什么 假设我有一个这样的听众: @StreamListener @Output(Urls.OUTUT) public Flux<String> expandUrls(@Input(Urls.INPUT) Flux<String> urlFormats) { return urlFormats .map(this::expandUrl)
@StreamListener
@Output(Urls.OUTUT)
public Flux<String> expandUrls(@Input(Urls.INPUT) Flux<String> urlFormats)
{
return urlFormats
.map(this::expandUrl)
.flatMapIterable(urls -> urls);
}
@StreamListener
@Output(Urls.OUTPUT)
public Flux<String> expandUrls(@Input(Urls.INPUT) Mono<String> urlFormats)
{
return urlFormats
.repeat(3)
.zipWith(pageNumbers)
.map(this::formatUrl);
}
其中页码为Flux.fromStreamStream.iterate1,p->p+1.limit3
我得到以下例外
Caused by: java.lang.IllegalArgumentException: A method annotated with @StreamListener may use @Input or @Output annotations only in declarative mode and for parameters that are binding targets or convertible from binding targets.
我这样做就排除了这个异常
@StreamListener(value = Urls.INPUT)
@Output(Urls.OUTPUT)
public Flux<String> expandUrls(Mono<String> urlFormats)
{
return urlFormats
.repeat(3)
.zipWith(pageNumbers)
.map(this::formatUrl);
}
我的问题是:如何将Mono与SpringCloudStream结合使用。甚至可以这样使用它吗?如果是,那么怎么做?
哦,我正在使用Kafka作为Kafka启动器的代理。Spring Cloud Stream StreamListener的@Input参数类型支持reactor类型的流量,因为它比@Input参数类型使用Mono更适合反应流应用程序。这只是因为对于该用例,SCSt不支持Mono。只有流量是足够的。
Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'http': was expecting ('true', 'false' or 'null')
at [Source: http://www.example.com/page-%d,1,0.html;