camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Raible <>
Subject Email Error on Route Exception
Date Thu, 22 May 2014 15:41:34 GMT
Hello all,

I'm getting up to speed on Apache Camel and trying to replace a "message
flow" that was originally written for IBM Message Broker 6.1. The flow
involves receiving input from a SOAP service, looking up a value in a
database, and returning that to the client (again, via SOAP). I have a
route that works and now I'm trying to add exception handling to it.
Ideally, an email can be generated when an exception occurs.

Here's my Route:

public class FooRoute extends RouteBuilder {

private String uri = "cxf:/foo?serviceClass=" + FooService.class.getName();

private Log log = LogFactory.getLog(FooRoute.class);

private MailSender mailSender;

private SimpleMailMessage mailMessage;

 public void configure() throws Exception {
.process(new Processor() {
 public void process(Exchange exchange) throws Exception {
Exception exception = (Exception)
 // email error
mailMessage.setText("WTF?!\n\n " + exception.getMessage());
// send the request to the route to handle the operation
 // the name of the operation is in that header
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
 // get the id from the input
String id = exchange.getIn().getBody(FooRequest.class).getId();
.to("sql:select value from table where id = #?dataSource=ds")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
 // get the value from the input
List<HashMap> data = (ArrayList<HashMap>) exchange.getIn().getBody();
 // todo: handle value is empty
FooResponse response = new FooResponse();

The problem that I'm experiencing is that the Autowired dependencies from
Spring are not getting set. Do I need to do something special to allow
Spring dependencies in my route or is there an easier way to send exception

Here's how I have my routes configured using Spring's JavaConfig:

public class CamelConfig extends CamelConfiguration implements
InitializingBean {

 * Returns the CamelContext which support Spring
protected CamelContext createCamelContext() throws Exception {
return new SpringCamelContext(getApplicationContext());

public List<RouteBuilder> routes() {
 List<RouteBuilder> routes = new ArrayList<>();
routes.add(new FooRoute());
return routes;

public void afterPropertiesSet() throws Exception {}



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message