Announcement Announcement Module
Collapse
No announcement yet.
Custom HTTP Headers Not Found In Wiretap on HTTP Request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom HTTP Headers Not Found In Wiretap on HTTP Request

    I have established SI channels that send HTTP requests from a client to SI to a REST service and back through SI to the client. I would like the contents of the request to get sent off on an audit channel to a service activator to do some unrelated auditing stuff. The request consists of a JSON payload and a bunch of headers, two of which are non-standard.

    There are two problems:
    • The message that hits my audit channel is missing the custom headers.
    • The JSON payload is represented on the audit channel as a byte[], but the byte array contents are converted to individual numbers that are concatenated to a String.

    Here is my configuration of the channels and endpoints:

    Code:
        <channel id="requestChannel">
            <interceptors>
                <wire-tap channel="auditChannel" />
            </interceptors>
        </channel>
    ...
       <channel id="auditChannel">
            <dispatcher task-executor="auditExecutor"/>
        </channel>
    ...
       <service-activator input-channel="auditChannel" ref="auditor" method="audit"/>
    Here are the logs:

    Code:
       21:42:27 DEBUG [o.s.i.c.DirectChannel.preSend] preSend on channel 'documentSearchAuditChannel', message: [Payload=[B@5d36d1d7][Headers={timestamp=1305754947444, id=f2532515-a899-49f6-9536-f38b8273ebff, errorChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@3a0aaa10, content-type=application/json;charset=UTF-8, http_requestMethod=POST, replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@3a0aaa10, accept=application/json, http_requestUrl=http://localhost:8080/myapp/documents/search}]
       21:42:27 DEBUG [o.s.i.h.ServiceActivatingHandler.handleMessage] ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@12231e35] received message: [Payload=[B@5d36d1d7][Headers={timestamp=1305754947444, id=f2532515-a899-49f6-9536-f38b8273ebff, errorChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@3a0aaa10, content-type=application/json;charset=UTF-8, http_requestMethod=POST, replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@3a0aaa10, accept=application/json, http_requestUrl=http://localhost:8080/myapp/documents/search}]
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value array<Byte>[123, 34, 97, 110, 100, 34, 58, 91, 34, 108, 111, 110, 100, 111, 110, 34, 93, 125] of byte[] to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 123 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '123'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 34 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '34'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 97 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '97'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 110 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '110'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 100 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '100'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 34 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '34'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 58 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '58'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 91 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '91'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 34 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '34'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 108 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '108'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 111 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '111'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 110 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '110'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 100 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '100'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 111 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '111'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 110 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '110'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 34 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '34'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 93 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '93'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converting value 125 of byte to @org.springframework.integration.annotation.Payload java.lang.String
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '125'
       21:42:27 DEBUG [o.s.c.c.s.GenericConversionService.convert] Converted to '123,34,97,110,100,34,58,91,34,108,111,110,100,111,110,34,93,125'
       21:42:27 DEBUG [m.a.i.i.a.AuditLogger.logQuery] Payload found: 123,34,97,110,100,34,58,91,34,108,111,110,100,111,110,34,93,125
    I have no idea how to map my custom HTTP headers to the wiretap channel, and I have no idea how to apply a MappingJacksonHttpMessageConverter to convert the payload JSON.

    Any insight is appreciated.

    Thanks.

  • #2
    I applied a simple transformer to turn the byte[] into a String for the JSON payload, but I am still missing headers. Any help is appreciated.

    Thanks.

    Comment


    • #3
      Did you apply header-mapper since you are talking about non-standard headers. See http://static.springsource.org/sprin...header-mapping

      Comment


      • #4
        I don't know how to apply header mappers to a simple wiretap:

        Code:
            <channel id="requestChannel">
                <interceptors>
                    <wire-tap channel="auditChannel" />
                </interceptors>
            </channel>
            <http:inbound-gateway id="inboundGateway"
                                  request-channel="requestChannel"
                                  reply-channel="replyChannel"
                                  name="/documents/search"
                                  supported-methods="POST"
                                  mapped-response-headers="content-type,accept"
                                  mapped-request-headers="content-type,accept"/>
        I need for the wiretap channel auditChannel to have access to all the headers as requestChannel does thanks to the mappings. I'm not sure how to apply a header mapper to allow this.

        Any insight is appreciated.

        Thanks.

        Comment


        • #5
          Actually never mind. I was confused about the order certain actions occur. I got it going now. Thanks.

          Comment

          Working...
          X