7 Replies Latest reply on Sep 10, 2014 8:27 AM by San Ebro

    Accessing Switchyard context from onCompletion when an exception occurs

    San Ebro Newbie

      Hello,

       

      I'm trying to do some audit work in which I have to store on database if certain action with certain data have been successfully carried out or not.

      I get this audit data from several earlier services which executes queries to several databases, and I'm storing necessary data on context, with exchange scope, just to keep them live along the whole route. By saying:

       

      context.setProperty("property", object, Scope.EXCHANGE);

       

      When all services are executed, I have an onCompletion clause on xml routing file, which gets necessary audit data from context and executes a query to store that info on an audit table on database. It tries to get scoped information from a message composer. Besides, if an exception is thrown, I need to audit that something went wrong and store this information on database too.

       

      Everything works fine if the whole route is executed successfully, but when an exception is thrown, the info I've been storing on context on each service execution is not available anymore.

       

      Is this the correct behavior? Is there an alternative way to do this?

       

      Thank you very much.