Announcement Announcement Module
Collapse
No announcement yet.
Logging - message life story Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Logging - message life story

    Hi Guys.

    i have a requirement in my Spring integration application to log all the events in a log.

    For example.
    message payload __________________
    message entered to channel channel1.
    message is entered to router router1.
    message redirects to channel channel2 from router router1
    ---
    ---

    i tried using <message-history/> with <logging-channel-adapter .../> but it provides only the information. can not customize to a proper logging story.

    Do you guys have any idea about this?

    thanks,
    kelum

  • #2
    Hi

    Your task can be solved with this one: Wire Tap

    Take care,
    Artem

    Comment


    • #3
      For unit tests I have used <message-history/> and the following code to verify the route taken was correct and in order. Perhaps you can get the information in the same way I did and create your custom logging.

      Code:
              MessageHistory mh = MessageHistory.read(message);
              assertThat(mh.size(), is(equalTo(13)));
      
              int index = 0;
              Properties props = TestUtils.locateComponentInHistory(mh, "ws-rawInboundChannel", index);
              assertThat(props, is(notNullValue()));
      
              props = TestUtils.locateComponentInHistory(mh, "enrichWithTransactionId", ++index);
              assertThat(props, is(notNullValue()));

      Comment


      • #4
        Hi Wrangler,

        really thanks for the help. i was able to use <message-history/> feature and create custom log using groovy as follows.

        Code:
        <int:service-activator id="logger" input-channel="errorChannel">
             <groovy:script>
        	   headers.history.each { println it }
        	   println '=' * 80
             </groovy:script>
        </int:service-activator>

        But i feel its not sufficient and i wanted to do some thing like you did in above code. So we have greater control over it. But i couldn't find a way of instantiating MessageHistory object as you did in your code. Can you please help me to find a way to instantiate MessageHistory object inside a POJO?

        Thanks,
        Kelumt

        Comment


        • #5
          I went to a POJO which has a Message object as a parameter and instantiated the MessageHistory object:
          Code:
                  MessageHistory history = MessageHistory.read(mssage);
                  for (int i = 0; i < history.size(); i++) {
                      Properties properties = history.get(i);
                      // could use properties.get("type") to filter what to log
                      // could use properties.get("timestamp") to log dts
                      logger.debug("history: " + properties.get("name"));
                  }

          Comment

          Working...
          X