Not sure I understand why I am getting compilation error on code below. I am looping a list DB Entities and if it does not exists in my main list then I create a new Camel Route and pass the entity as a Parameter to another class.
@Component
public class MailRouteProcess implements Processor {
private static List<MailDataSource> mailDSList = new ArrayList<>();
@Autowired
MailDataSourceService mailDataSourceService;
@Autowired
private ApplicationContext applicationContext;
@Autowired
CamelContext camelContext;
@Override
public void process(Exchange exchange) throws Exception {
List<MailDataSource> mailDataSourceList = mailDataSourceService.findAll();
for(MailDataSource mailDataSource : mailDataSourceList) {
if(!mailDSList.contains(mailDataSource)) {
camelContext=(CamelContext)applicationContext.getBean("mainCamelContext");
camelContext.addRoutes(new MailRouteBuilder(camelContext, mailDataSource));
mailDSList.add(mailDataSource);
}
}
}
}
Then in my MailRouteBuilder class I have:
@Component
public class MailRouteBuilder extends RouteBuilder {
public MailRouteBuilder(CamelContext camelContext, MailDataSource mailDataSource) {
super(camelContext);
}
But getting the following compilation error on the MailDataSource mailDataSource:
Could not autowire. No Beans of 'MailDataSource' type found.
Any ideas?
You are trying to instantiate your MailRouteBuilder in two different ways:
To sum it up, the error stems not from passing an instance to another and one, but from failed autowiring. (Do you need your MailRouteBuilder to be a managed component?)