0

Which exception is thrown when Camel route toF("sql:insert into ...") fails due to db connection issue?

I've try to capture like onException(CannotCreateTransactionException.class, ConnectionException.class) but it's not capturing. If i can capture it, i want to do up to 3 redeliveries and call other process something like below

.maximumRedeliveries(3)
.redeliveryDelay(10000)
.process("ConnectionExceptionProcess")
.end()

Thanks,

Julia
  • 133
  • 11

1 Answers1

0

sql component can throw more than one error type. DataAccessException , IllegalArgumentException , SQLException, etc . You can solve this problem by performing only sql operations on the route you will create.You call this place from other routes

public class SqlOperationRoute extends RouteBuilder {

@Override
public void configure() {

    onException()
            .maximumRedeliveries(3)
            .process("myProcessor")
            .end();

    from("direct:insert")
            .to("sql:insert into table x .....");

    from("direct:get")
            .to("sql: select  from ....");
}

}

erayerdem
  • 775
  • 6
  • 12
  • Thanks for your answer. I do have a question. so let say I have Insert statement what exception will be thrown? Can you help me where I can find what kind of exception will be thrown for specific situation? – Julia Sep 19 '21 at 13:26
  • check out SqlProducer . sql component uses spring jdbctemplate – erayerdem Sep 19 '21 at 13:59