title: Spring Integration : How to intercept ALL spring integration component and fetch attribute values to log
body: <p>I need to intercept ALL the Spring Integration components at runtime and should be able to fetch the attribute values in order to log a meaningful message.
  For example: </p>
  
  <pre><code>&lt;int-http:outbound-gateway url="someURL" http-method="GET"
                             request-channel="channel1"
                             expected-response-type="com.example.Test"
                             message-converters="customMessageConverters"&gt;
      &lt;int-http:uri-variable name="testId" expression="headers.testId"/&gt;
  &lt;/int-http:outbound-gateway&gt;
  </code></pre>
  
  <p>In the example above, I need to intercept int-http:outbound-gateway and capture the value for url, request-channel and expected-response-type. We need to do this for all http outbound gateway.</p>
  
  <p>Similarly, for all other components like int-http:inbound-gateway, int-http:inbound-channel-adapter, int:transformer, int:header-enricher, int:chain, int:router, etc.</p>
  
  <p>I have tried creating a custom class implementing BeanPostProcessor - postProcessAfterInitialization method. Checked for the bean name to be matching with the component, and tried to retrieve all the details but the beans are created and this method is called at the server startup itself. My requirement is to capture the flow as and when the user navigates and any particular route is being called. Also I am not able to find Java class name for all the component apart from the below. Still finding for the rest.
  org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway for int-http:inbound-gateway, org.springframework.integration.http.outbound.AbstractHttpRequestExecutingMessageHandler for int-http:outbound-gateway</p>
  
  <p>Update:
  I have tried the below but cant see any extra output in logs with respect to message history. Is anything missing in the above code?</p>
  
  <pre><code>&lt;int:message-history /&gt;
  &lt;int:logging-channel-adapter id="logging"
      log-full-message="true" logger-name="message.history" level="DEBUG"/&gt;
      &lt;int:wire-tap pattern="*" order="3" channel="logging" /&gt; 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;int:message-history /&gt; 
      &lt;int:logging-channel-adapter id="logger"
      log-full-message="true" logger-name="message.history" level="DEBUG"/&gt;
  &lt;int:channel id="wiretapChannel"&gt;
      &lt;int:interceptors&gt;
          &lt;int:wire-tap channel="logger"/&gt;
      &lt;/int:interceptors&gt;
  &lt;/int:channel&gt;  
  </code></pre>
  
  <p>Also, I am trying to inject LogMessage into wire-tap inorder to perform some additional tasks from MessageHistory data. But the control doesn't enter handleMessage method. Please help.</p>
  
  <pre><code>&lt;bean id="logMessage" class="com.logging.LogMessage"/&gt; 
  &lt;int:service-activator input-channel="wiretapChannel" ref="logMessage" method="handleMessage"&gt;&lt;/int:service-activator&gt;
  
  public class LogMessage {
  public void handleMessage(org.springframework.messaging.Message&lt;?&gt; message) throws MessagingException {
  MessageHistory history = MessageHistory.read(message);
  for (int i = 0; i &lt; history.size(); i++) {
      Properties properties = history.get(i);
      getLogger().info("history: " + properties.get("name"));
  }    
  }
  }
  </code></pre>