org.fusesource.examples.errors
Class OrderService

java.lang.Object
  extended by org.fusesource.examples.errors.OrderService

public class OrderService
extends java.lang.Object

An order service implementation that provides one method to do validation and another method that just randomly throws Exceptions to be able to test error handling in our Camel route.


Constructor Summary
OrderService()
           
 
Method Summary
 void randomlyThrowRuntimeException(java.lang.String name)
          This method throws a runtime exception 2 out of 3 times.
 void validateOrderDate(java.lang.String date)
          Validate the order date - orders should only be place from Monday to Saturday.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderService

public OrderService()
Method Detail

validateOrderDate

public void validateOrderDate(@XPath(value="/order:order/order:date",namespaces=@NamespacePrefix(prefix="order",uri="http://fusesource.com/examples/order/v7"))
                              java.lang.String date)
                       throws OrderValidationException
Validate the order date - orders should only be place from Monday to Saturday. This method can be used as a plain Java method, but when it is used inside a Camel route, the @XPath annotation will kick in, evaluating the XPath expression and using the result as the method parameter. In this case, it will fetch the order date from the order XML message.

Parameters:
date - the order date
Throws:
OrderValidationException - when the order date is a Sunday

randomlyThrowRuntimeException

public void randomlyThrowRuntimeException(@Header(value="CamelFileName")
                                          java.lang.String name)
This method throws a runtime exception 2 out of 3 times. This is completely useless in real life, but in this example we use this to demonstrate Camel's error handling capabilities. In order to be able to log which file is being processed when throwing the exception, we the Camel @Header annotation to extract the file name from the message.

Parameters:
name - the file name


Copyright © 2012 FuseSource. All Rights Reserved.