Results 1 to 5 of 5

Thread: Logging - message life story

  1. #1

    Default 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. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    632

    Default

    Hi

    Your task can be solved with this one: Wire Tap

    Take care,
    Artem

  3. #3

    Default

    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()));

  4. #4

    Default

    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

  5. #5

    Default

    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"));
            }

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
  •