Apache Camel OnExeption

cs_Taz1984 Messages postés 47 Date d'inscription lundi 20 juillet 2009 Statut Membre Dernière intervention 13 mars 2013 - 7 janv. 2013 à 11:35
cs_Taz1984 Messages postés 47 Date d'inscription lundi 20 juillet 2009 Statut Membre Dernière intervention 13 mars 2013 - 7 janv. 2013 à 14:18
Bonjour,

j'ai différentes routes en Camel, je voudrais que lorsque une exception apparaît le programme puisse router vers une route erreur juste pour afficher l exception.

J'ai mis au début de mon programme (En DSL).

onException(Exception.class).to(endpoint);


Que dois je mettre dans ce endpoint ?

auriez vous une idée ? ou des exemples pour la gestion des exeptions ?!!

Merci d'avance

1 réponse

cs_Taz1984 Messages postés 47 Date d'inscription lundi 20 juillet 2009 Statut Membre Dernière intervention 13 mars 2013
7 janv. 2013 à 14:18
j'ai ajouté un BeanErreur ,

onException(Exception.class).process(new MyFunctionFailureHandler()).stop();


Voici la définition de MyFunctionFailureHandler.

public class MyFunctionFailureHandler  implements Processor {

@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
 // the caused by exception is stored in a property on the exchange
        Throwable caused = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
        // here you can do what you want, but Camel regard this exception as handled, and
        // this processor as a failurehandler, so it wont do redeliveries. So this is the
        // end of this route. But if we want to route it somewhere we can just get a
        // producer template and send it.

        // send it to our mock endpoint
        exchange.getContext().createProducerTemplate().send("mock:myerror", exchange);
}

}


j'ai crée une exeption de type 0/0 NumberExeption mais rien ne se passe
0
Rejoignez-nous