Apache骆驼反应流抛出该流没有主动订阅
我只是尝试使用骆驼反应流与Spring Boot反应器一起使用以下代码
package com.manning.camel.reactive;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
/**
* A simple Camel route that triggers from a timer and calls a bean and prints to system out.
* <p/>
* Use <tt>@Component</tt> to make Camel auto-detect this route when starting.
*/
@RestController
public class MySpringBootRouter extends RouteBuilder {
@Autowired
private ProducerTemplate template;
@Autowired
private CamelReactiveStreamsService crss;
@GetMapping
public Mono<String> sayHi() {
template.asyncSendBody("direct:works", "Hi");
//return Mono.from(crss.fromStream("greet", String.class));
return Mono.from(crss.fromStream("greet", String.class));
}
@Override
public void configure() {
from("direct:works")
.log("Fired")
.to("reactive-streams:greet");
}
}
,然后运行代码
java.lang.illegalstateexception:该流没有活动订阅
I'm just trying use Camel Reactive Stream together with Spring Boot Reactor using the following code
package com.manning.camel.reactive;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
/**
* A simple Camel route that triggers from a timer and calls a bean and prints to system out.
* <p/>
* Use <tt>@Component</tt> to make Camel auto-detect this route when starting.
*/
@RestController
public class MySpringBootRouter extends RouteBuilder {
@Autowired
private ProducerTemplate template;
@Autowired
private CamelReactiveStreamsService crss;
@GetMapping
public Mono<String> sayHi() {
template.asyncSendBody("direct:works", "Hi");
//return Mono.from(crss.fromStream("greet", String.class));
return Mono.from(crss.fromStream("greet", String.class));
}
@Override
public void configure() {
from("direct:works")
.log("Fired")
.to("reactive-streams:greet");
}
}
After run the code
java.lang.IllegalStateException: The stream has no active subscriptions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很长一段时间后,解决了错误,可以注意到路由器类逻辑有点更改了
After a long time, solved the error, as can be noticed the Router Class logic was changed a little