I use Apache Camel for a projet and I would like to use the produce annotation to send an object in a file. 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. You have to define it inside a spring context as a spring bean to make the annotations work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.