Results 1 to 3 of 3

Thread: Logging in Chain

  1. #1
    Join Date
    May 2009
    Location
    Rus
    Posts
    87

    Default Logging in Chain

    I have a chain configured, there are elements like filters, transformers and validators. I'd like to add logging between them, is it possible? Don't want to create a separate class for logging, would like to use standard logging-channel-adapter.
    Code:
        <si:chain input-channel="input">
            <si:transformer ref="some transformer"/>
            <si:filter ref="validator" discard-channel="validation.failure"/>
            <si:splitter ref="another transformer">
                <jdbc:outbound-channel-adapter channel="jdbcinputchannel" data-source="dataSource">
                    <jdbc:query>
                        query
                    </jdbc:query>
                </jdbc:outbound-channel-adapter>
            </si:splitter>
        </si:chain>

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Well, the <chain/> is really intended as a black box.

    <logging-channel-adapter/> won't work because that is a one-way element (no reply to send to the next component).

    You'd have to do something like this...

    Code:
    public class Logger {
    	
    	private static Log logger = LogFactory.getLog(Logger.class);
    			
    	public Message<?> log(Message<?> message) {
    		logger.info("CHAIN:" + message);
    		return message;
    	}
    
    }
    
    <beans:bean id="log" class="foo.Logger"/>
    
    <si:chain input-channel="input">
            <service-activator ref="log" />
            <si:transformer ref="some transformer"/>
            <service-activator ref="log" /> 
            <si:filter ref="validator" discard-channel="validation.failure"/>
            <service-activator ref="log" />
            <si:splitter ref="another transformer">
                <jdbc:outbound-channel-adapter channel="jdbcinputchannel" data-source="dataSource">
                    <jdbc:query>
                        query
                    </jdbc:query>
                </jdbc:outbound-channel-adapter>
            </si:splitter>
            <service-activator ref="log" />
    </si:chain>
    Either that, or break up your chain and wire-tap explicit channels between the elements.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    May 2009
    Location
    Rus
    Posts
    87

    Default

    Eh.. I see, thanks for your answer!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •