2 Replies Latest reply on Mar 28, 2011 5:10 PM by joe_boy12

    Exception handling in ESB

    vishnumathi

      Hi

      i am new to jboss and ESB.. am wking with a proj where there is a service inside which there are 2 actions

       

      a message is passed to action1 it does some process and passes it to action2. action2 does something and returns the result to consumer..

       

       

      my scenario is when there is some exception in action1 then the service should break and return the message to consumer instead of going to action2

       

      can any1 help me in doing this..?

        • 1. Re: Exception handling in ESB
          tomeicher

          action1 can terminate the pipeline by returning null.

          Cheers, Tom.

          • 2. Re: Exception handling in ESB
            joe_boy12

            I want to send custom XML reply when exceptions happen so I wrote following in @onException method..

            somehow its not sending custom message but sends a complete stack trace of exception that caused the execution on this method. Any idea?

             

            @OnException
            public void error( Message msg )
            {
            if( log.isInfoEnabled())
            {
              log.info("+++++++++++++++++++ In error() +++++++++++++ :: OUCH " + msg.getFault());
            }

            String error = "<fault code=\"111\" order_id=\"O1234567\"><cause desc=\"SOMETHING BAD HAPPENED\"/></fault>";
            msg.getBody().add(error);

            HttpResponse response = new HttpResponse(200);
            //HttpResponse response = HttpResponse.getResponse(msg); // throws NPE
            response.setContentType("text/xml");
            response.setEncoding("UTF-8");
            response.setResponse(msg);
            }