Auditing an exception response
objectiser Nov 21, 2012 5:34 AMHi,
I've created a simple auditor but I'm having trouble observing an exception being returned instead of a message response. The auditor is:
package org.test; import org.switchyard.bus.camel.processors.Processors; import org.apache.camel.Exchange; import org.switchyard.bus.camel.audit.Audit; import org.switchyard.bus.camel.audit.Auditor; import javax.inject.Named; @Audit //({Processors.CONSUMER_CALLBACK}) @Named("Error handler") public class ErrorHandler implements Auditor { @Override public void beforeCall(Processors processor, Exchange exchange) { System.out.println("Before " + processor.name()+ " exchange="+exchange); if (exchange.isFailed()) { System.out.println("EXCHANGE FAILED"); } System.out.println("Exception: "+exchange.getException()); System.out.println("Out: "+exchange.getOut()); } @Override public void afterCall(Processors processor, Exchange exchange) { System.out.println("After " + processor.name()+ " exchange="+exchange); if (exchange.isFailed()) { System.out.println("EXCHANGE FAILED"); } System.out.println("Exception: "+exchange.getException()); System.out.println("Out: "+exchange.getOut()); } }
I've attached the full log, but basically I get the following information from all of the callbacks:
10:18:16,112 INFO [stdout] (ODEServer-1) After PROVIDER_CALLBACK exchange=Exchange[Message: [Body is null]]
10:18:16,113 INFO [stdout] (ODEServer-1) Exception: null
10:18:16,113 INFO [stdout] (ODEServer-1) Out: Message: [Body is null]
Although the javadoc for the 'isFailed' method on the exchange indicates that it will be true if a fault or exception is returned, this is returning false - and the exception and out message appear to be empty. Not sure how to determine and access the exception?
Another question is, what occurs in the DOMAIN_HANDLERS to change the camel exchange's toString from initially reporting the request contents, to showing it as "Body is null"?
10:18:15,260 INFO [stdout] (http--127.0.0.1-8080-1) Before DOMAIN_HANDLERS exchange=Exchange[Message: <loan:request xmlns:loan="http://example.com/loan-approval/loanService/">
10:18:15,261 INFO [stdout] (http--127.0.0.1-8080-1) <loan:firstName>Fred</loan:firstName>
10:18:15,261 INFO [stdout] (http--127.0.0.1-8080-1) <loan:name>Bloggs</loan:name>
10:18:15,262 INFO [stdout] (http--127.0.0.1-8080-1) <loan:amount>1000</loan:amount>
10:18:15,262 INFO [stdout] (http--127.0.0.1-8080-1) </loan:request>]
10:18:15,262 INFO [stdout] (http--127.0.0.1-8080-1) Exception: null
10:18:15,262 INFO [stdout] (http--127.0.0.1-8080-1) Out: Message: [Body is null]
10:18:15,266 INFO [stdout] (http--127.0.0.1-8080-1) After DOMAIN_HANDLERS exchange=Exchange[Message: [Body is null]]
10:18:15,266 INFO [stdout] (http--127.0.0.1-8080-1) Exception: null
10:18:15,266 INFO [stdout] (http--127.0.0.1-8080-1) Out: Message: [Body is null]
Thanks in advance.
Regards
Gary
-
server.log.zip 7.1 KB