The idea is to filter the sources, replacing @<var>@ occurrences with the mapping for <var> (which is currently hard-coded). @@ -> @. In order to make this work, I had to move the doc sources one directory down (into akka-docs/rst) so that the filtered result could be in a sibling directory so that relative links (to _sphinx plugins or real code) would continue to work. While I was at it I also changed it so that WARNINGs and ERRORs are not swallowed into the debug dump anymore but printed at [warn] level (minimum). One piece of fallout is that the (online) html build is now run after the normal one, not in parallel.
42 lines
No EOL
1.3 KiB
Java
42 lines
No EOL
1.3 KiB
Java
package docs.camel;
|
|
//#ErrorThrowingConsumer
|
|
import akka.actor.Status;
|
|
import akka.camel.CamelMessage;
|
|
import akka.camel.javaapi.UntypedConsumerActor;
|
|
import org.apache.camel.builder.Builder;
|
|
import org.apache.camel.model.ProcessorDefinition;
|
|
import org.apache.camel.model.RouteDefinition;
|
|
import scala.Option;
|
|
|
|
public class ErrorThrowingConsumer extends UntypedConsumerActor{
|
|
private String uri;
|
|
|
|
public ErrorThrowingConsumer(String uri){
|
|
this.uri = uri;
|
|
}
|
|
|
|
public String getEndpointUri() {
|
|
return uri;
|
|
}
|
|
|
|
public void onReceive(Object message) throws Exception{
|
|
if (message instanceof CamelMessage) {
|
|
CamelMessage camelMessage = (CamelMessage) message;
|
|
String body = camelMessage.getBodyAs(String.class, getCamelContext());
|
|
throw new Exception(String.format("error: %s",body));
|
|
} else
|
|
unhandled(message);
|
|
}
|
|
|
|
@Override
|
|
public ProcessorDefinition<?> onRouteDefinition(RouteDefinition rd) {
|
|
// Catch any exception and handle it by returning the exception message as response
|
|
return rd.onException(Exception.class).handled(true).transform(Builder.exceptionMessage()).end();
|
|
}
|
|
|
|
@Override
|
|
public void preRestart(Throwable reason, Option<Object> message) {
|
|
getSender().tell(new Status.Failure(reason), getSelf());
|
|
}
|
|
}
|
|
//#ErrorThrowingConsumer |