Announcement Announcement Module
Collapse
No announcement yet.
Logging in Chain Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      Eh.. I see, thanks for your answer!

      Comment

      Working...
      X