olger
May 1st, 2008, 03:15 PM
Im looking into the error handling of integration to achieve the following: When an exception occurs, I'd like to store the original payload (in some format, assume XML) along with the error. (why the payload ? -> I like self-healing / auto recovery concepts.. )
In order todo so, I have two options (right?)
1) give the endpoint an error-handler that implements the ErrorHandler interface:
public interface ErrorHandler {
void handle(Throwable t);
}
Do you see any issues to have handle like
void handle(Message<?> message, Throwable t);
This gives the option to log the original message / payload when an error occurs.
2) Grab the error off the errorChannel
I'd prefer to do this as I am able to write a single error handler that stores the required payload at a single spot, in a single way. I'd expect a similar interface as the ErrorHandler interface and have read (documentation) that it gives ErrorMessages.
Somehow this is not working at my side and I could not simply figure out the way the errorChannel works.
I configured:
<bean id="errorMessageHandler" class="org.joiningtracks.his.support.util.event.LoggingMe ssageHandler"/>
<bean id="ldapMessageErrorHandler" class="org.joiningtracks.his.service.ldap.impl.LdapPatien tMessageErrorHandler"/>
<!-- configure spring integration context -->
<integration:message-bus error-channel="errorChannel"/>
<integration:channel id="errorChannel" publish-subscribe="true" capacity="500"/>
<integration:handler-endpoint input-channel="errorChannel" handler="errorMessageHandler" error-handler="ldapMessageErrorHandler">
<integration:concurrency core="5" max="25" queue-capacity="20" keep-alive="120"/>
</integration:handler-endpoint>
the errorMessageHandler is a simple class that implements the MessageHandler interface and thereafter simply logs the whole (it does not do yet what I intented... that is next)
At this moment, I don't see any messages coming, so one question is: what is wrong with this configuration ?
And the other question, does the ErrorMessages give the original payload / message ?
In order todo so, I have two options (right?)
1) give the endpoint an error-handler that implements the ErrorHandler interface:
public interface ErrorHandler {
void handle(Throwable t);
}
Do you see any issues to have handle like
void handle(Message<?> message, Throwable t);
This gives the option to log the original message / payload when an error occurs.
2) Grab the error off the errorChannel
I'd prefer to do this as I am able to write a single error handler that stores the required payload at a single spot, in a single way. I'd expect a similar interface as the ErrorHandler interface and have read (documentation) that it gives ErrorMessages.
Somehow this is not working at my side and I could not simply figure out the way the errorChannel works.
I configured:
<bean id="errorMessageHandler" class="org.joiningtracks.his.support.util.event.LoggingMe ssageHandler"/>
<bean id="ldapMessageErrorHandler" class="org.joiningtracks.his.service.ldap.impl.LdapPatien tMessageErrorHandler"/>
<!-- configure spring integration context -->
<integration:message-bus error-channel="errorChannel"/>
<integration:channel id="errorChannel" publish-subscribe="true" capacity="500"/>
<integration:handler-endpoint input-channel="errorChannel" handler="errorMessageHandler" error-handler="ldapMessageErrorHandler">
<integration:concurrency core="5" max="25" queue-capacity="20" keep-alive="120"/>
</integration:handler-endpoint>
the errorMessageHandler is a simple class that implements the MessageHandler interface and thereafter simply logs the whole (it does not do yet what I intented... that is next)
At this moment, I don't see any messages coming, so one question is: what is wrong with this configuration ?
And the other question, does the ErrorMessages give the original payload / message ?