简体   繁体   English

使用 Apache Camel 进行端点注入

[英]Endpoint Injection with Apache Camel

I use Apache Camel for a projet and I would like to use the produce annotation to send an object in a file.我将Apache Camel用于一个项目,并且我想使用产品注释来发送文件中的对象。 First, is it possible ?首先,可能吗? Is there a better way ?有没有更好的办法 ?

Secondly, I tried this snippet code:其次,我尝试了这个片段代码:

public class MyProducer {

  private static final String MEDIA = "file:";

  private static final String PATH = "c:/directory";

  @Produce(uri = MEDIA + PATH)
  protected ProducerTemplate producer;

  public void publish(MyObject o) {
    producer.sendBody(o);
  }
}

When I call the publish methode the producer is not inject (null).当我调用发布方法时,生产者没有注入(空)。 Anybody have an idea ?有人有想法吗? Thanks in advance.提前致谢。

It depends on how you create the MyProducer class.这取决于您如何创建 MyProducer 类。 You have to define it inside a spring context as a spring bean to make the annotations work.您必须在 spring 上下文中将其定义为 spring bean 才能使注释起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM