java - 无法确定为什么 Smallrye/camel 代码片段未编译 : no subscriber method in camel context obj?

标签 java apache-camel maven-3 smallrye-reactive-messaging

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/

相关文章:

java - Apache Camel 文件组件 - 如何只扫描新文件?

java - Apache Camel - 在启动时触发任务仅运行一次

java - Camel : stop the route when the jdbc connection loss is detected

maven - 使用maven-shade-plugin,但是依赖类不在最终的jar中

java - 用于测试的 Maven 配置文件

java - 正则表达式替换为捕获重复组

Java selenium 3.6.0 无法设置配置文件

Spring Boot 2.2.1 在 Build 时创建两个 jar

java - 什么时候在java中创建数组类?

java - Java中的队列操作