smallrye 文档(来自 https://smallrye.io/smallrye-reactive-messaging/ )引用了一个我在编译时遇到问题的示例代码片段...
即,
10.4. Using Camel Route in @Incoming method
Here is an example of method annotated with @Incoming directly using a Camel route:
[...]
@Inject
private CamelContext camel; <<==
@Inject
private CamelReactiveStreamsService camel_reactive;
[...]
@Incoming("camel")
public Subscriber<String> sink() {
return camel.subscriber("file:./target?fileName=values.txt&fileExist=append", String.class);
}
--似乎“camel”对象 - 即“camel.subscriber”(上面) - 没有与之关联的“subscriber”方法(?)。
编译错误看起来像这样......
cannot find symbol
symbol: method subscriber(java.lang.String,java.lang.Class<java.lang.String>)
location: variable camel of type org.apache.camel.CamelContext
我在我的 Maven pom.xml 中包含了以下依赖项(最初只是第一个依赖项 - 然后添加了第二个依赖项,拼命尝试让这个示例片段正常工作 - 也尝试了版本 1.0.8)
<!-- camel support -->
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-camel</artifactId>
<version>1.0.7</version>
</dependency>
<!-- ampq -->
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-amqp</artifactId>
<version>1.0.7</version>
</dependency>
希望熟悉camel和/或smallrye响应式(Reactive)消息传递的人能够识别导致编译错误的问题吗?
谢谢!
最佳答案
好吧,作为 Smallrye 等的新手,我成了逐字逐句阅读文档的受害者。 但是,“camel.subscriber”似乎是文档中的编辑错误。 应该写成:“camel_reactive.subscriber”。
立即编译查找。
关于java - 无法确定为什么 Smallrye/camel 代码片段未编译 : no subscriber method in camel context obj?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58925759/