1
votes

I'm trying to implement a fire-and-forget flow to log messages on a database by calling an Oracle procedure, everything works fine but I'd like to log any exception I get when, by any chance, I misconfigured the xml or whatever else could go wrong (any exception thrown by the procedure?). I've searched for quite some time but I'm probably missing out something...

Here's the actual setting: I've got a gateway interface

public interface gatewayInterfaceDEF{
    void monitoring(Object payload);
}

XML definition of the gateway

<int:gateway service-interface="gatewayInterfaceDEF">
        <int:method name="monitoring" request-channel="monitoringGatewayInbound" />
</int:gateway>

Then the JDBC-outbound-gateway xml configuration that calls an oracle procedure:

<int:channel id="monitoringGatewayInbound">
    <int:dispatcher task-executor="monitoringTaskExecutor"/>
</int:channel>

<int-jdbc:stored-proc-outbound-gateway
    id="monitoringGatewayProcedure" request-channel="monitoringGatewayInbound"
    data-source="dataSource" stored-procedure-name="procedureName"
    return-value-required="false" ignore-column-meta-data="true">
    <int-jdbc:sql-parameter-definition
        someparameters />
    <int-jdbc:parameter parameter mapping />
</int-jdbc:stored-proc-outbound-gateway>

Thanks in advance

I've found this: http://java.dzone.com/articles/spring-async-and-exception But it's not working: could it be me not being able to implement it, but still.

UPDATE: the wrapped log I get.

|TEST|2014-10-17 17:09:08,999|||059EF53A6C4D2F67E0540003BA7A7C43|[monitoringTaskExecutor-1]|INFO |STDOUT|17:09:08,999 ERROR [LoggingHandler] org.springframework.integration.MessageHandlingException: error occurred in message handler [org.springframework.integration.jdbc.StoredProcOutboundGateway#0]

UPDATE2: the jboss-log4j.xml I'm using

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="STDFILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
        <param name="append" value="true" />
        <param name="file" value="/var/share/test/logs/test-ws_out.log" />
        <param name="datePattern" value="yyyy-MM-dd" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="TEST|%d|%X{req.remoteHost}|%X{sessionid}|%X{lcontext}|[%t]|%-5p|%c|%m%n|" />
        </layout>
    </appender>

    <root>
        <level value="INFO" />
        <appender-ref ref="STDFILE" />
    </root>
</log4j:configuration>
1
Good. Thanks for logs. Now show, please, your logger config. It's interesting how your categories are configured. And share, please, an info in which environment you are: Tomcat, WebSphere etc.Artem Bilan
Sorry I was on mobile and I didn't manage to format it. I'm updating the log4j now and I'm using the JBoss one, in its folder. (To find that log I had to use a default one). I'll be outside the workplace till monday, so I'm not sure if I'll be able to answer properly... (I'm deploying on JBoss 5.1 If I remember correctly)Massimo
we are using spring-integration version 3.0.2 and spring 3.1.8. Any news?Massimo
It doesn't matter. I think the root of issue is somewhere in the JBOSS, as it catches all logs and print them under that category.Artem Bilan
You were right: we deployed on WebLogic and the error is now showing with the proper severity. Thank you very much Artem.Massimo

1 Answers

0
votes

Since you are using ExcutorChannel, any Exception from the downstream flow is wrapped to the ErrorMessage and sent to the default errorChannel: http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/configuration.html#namespace-errorhandler

By default all those exceptions are looged by LoggingHandler under category org.springframework.integration.handler with ERROR level.

From other side you can add ExpressionEvaluatingRequestHandlerAdvice to the <int-jdbc:stored-proc-outbound-gateway>: http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/messaging-endpoints-chapter.html#expression-advice

And get deal with exception just only on that target MessageHandler