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>


希望有人精通骆驼和/或Smallrye反应式消息传递能识别导致编译错误的问题吗?

谢谢!

最佳答案

好吧,作为Smallrye等人的新手,我成了逐字逐句阅读文档的受害者。
但是,似乎“ camel.subscriber”是文档中的编辑错误。
应该已经写成:“ camel_reactive.subscriber”。

编译立即查找。

07-24 21:53