Announcement Announcement Module
Collapse
No announcement yet.
tcp-inbound-gateway error-channel assistance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Wrangler, I was going through this thread, Could you please share the final code snippet along with the wiring snap shot please. Thanks.

    Comment


    • #17
      Originally posted by JeevanSpring View Post
      Wrangler, I was going through this thread, Could you please share the final code snippet along with the wiring snap shot please. Thanks.
      It has been a while since I looked at this thread, or the code. My exception handling starts at the gateway, which has the property error-channel="inboundGatewayErrorChannel", which is just a channel definition.

      At one time I started to look into the channel having a queue:
      Code:
      <!--The gateway error channel is a queue channel so it runs in a separate thread form the source-->
          <int:channel id="inboundGatewayErrorChannel">
              <!--<int:queue capacity="25"/>-->
          </int:channel>
      My next step wqas to set up a service activtor, so a POJO can do some useful business logic, which for me is building a proper SOAP fault as a String of XML.
      Code:
          <int:service-activator id="gatewayErrorHandler"
                                 input-channel="inboundGatewayErrorChannel"
                                 output-channel="outboundGatewayErrorChannel"
                                 method="onErrorMessage">
              <beans:bean class="com...audit.DefaultErrorMessageHandler"/>
          </int:service-activator>
      The XML string is placed in a Message<String> for the service activator response, which goes to the service activator's output-channel:
      Code:
      responseMessage = MessageBuilder.withPayload(stringMessage)
                      .setReplyChannel((MessageChannel) errorMessage.getHeaders().getReplyChannel())
                      .copyHeadersIfAbsent(failedMessage.getHeaders())
                      .setHeader("errorMessage", "DefaultErrorMessageHandler")
                      .build();
      The service activator's output-channel, is intercepted with a wiretap:
      Code:
      <int:channel id="outboundGatewayErrorChannel" datatype="java.lang.String">
              <int:interceptors>
                  <int:wire-tap channel="gatewayExceptionAuditChannel"/>
              </int:interceptors>
          </int:channel>
      Since we have a particular way to do async audit logging with a POJO, I use a wiretap POJO, for which the output is then bridged to the gateway output channel. Our audut logging can toggled to enabled/disabled using an external property file value.
      Code:
          <int:bridge id="bridgeErrorToClient" 
                      input-channel="outboundGatewayErrorChannel"
                      output-channel="outboundChannel"/>
      
          <int:channel id="gatewayExceptionAuditChannel"  datatype="java.lang.String"/>
          <int:header-enricher input-channel="gatewayExceptionAuditChannel" 
                                      output-channel="auditLoggingChannel">
              <int:header name="sequenceName" value="0000 Exception caught at gateway"/>
              <int:header name="keyword" value="gateway error"/>
              <int:header name="loggingEnabled" value="${gateway.logging.enabled}"/>
              <int:header name="auditDirection" expression="T(com...audit.AuditLoggingDirection).ERROR"/>
          </int:header-enricher>

      Comment

      Working...
      X