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

  • RMI gateway error channel issues

    Hi,

    I'm using a pair of RmiOutboundGateway/RmiInboundGateway. Regular message flow through the requestChannel and replyChannel works fine.

    If there are exceptions downstream from the RmiInboundGateway, they need to be routed back to the endpoint upstream of the RmiOutboundGateway. While implementing this scenario, I discovered some issues with error message handling by the RMI gateway implementations (Spring Integration 2.2.3).
    1. If an exception is propagated from RmiInboundGateway to RmiOutboundGateway, the exception is always sent to the special channel "errorChannel". RmiOutboundGateway does not correctly check if the original outgoing message had an "errorChannel" header.
    2. RmiInboundGateway inherits from MessagingGatewaySupport and therefore should allow setting its "errorChannel" property. The si-rmi schema does not allow attribute "errorChannel" for <si-rmi:inbound-gateway>.

    I've implemented a work-around for those issues, but they make error message routing harder than it should be, imho. The work-around makes sure to avoid the exception handling logic of the outbound gateway by wrapping the exception with a suitable serializable object, which is not a Throwable. When the wrapped error reply arrives at the outbound gateway, a payload-dependent router can decide to route the reply message to the replyChannel or the errorChannel specified by the originating request message.

    Here's a sample definition of the outbound gateway - note that only the gateway bean should be required.

    Code:
    ...
    xmlns:si="http://www.springframework.org/schema/integration"
    xmlns:si-rmi="http://www.springframework.org/schema/integration/rmi"
    ...
    xsi:schemaLocation=
    ...
    http://www.springframework.org/schema/integration 
    http://www.springframework.org/schema/integration/spring-integration-2.2.xsd
    http://www.springframework.org/schema/integration/rmi http://www.springframework.org/schema/integration/rmi/spring-integration-rmi-2.2.xsd
    ...
    
        <si-rmi:outbound-gateway 
            request-channel="xmlRequestChannel" reply-channel="rmiReplyChannel"
            remote-channel="rmiInboundChannel" 
            host="${java.rmi.server.hostname:localhost}" port="${rmi.registry.port:0}"
            request-timeout="${rmi.request.timeout:20000}" reply-timeout="${rmi.reply.timeout:20000}">
            <si:poller fixed-delay="100" receive-timeout="60000" />
        </si-rmi:outbound-gateway>
        
        <si:channel id="rmiReplyChannel"/>
    
        <si:payload-type-router input-channel="rmiReplyChannel" default-output-channel="xmlReplyChannel">
            <si:mapping type="java.security.GuardedObject" channel="guardedErrorChannel" />
        </si:payload-type-router>
    
        <si:channel id="guardedErrorChannel"/>
    
        <si:transformer input-channel="guardedErrorChannel" output-channel="plainErrorChannel" 
            expression="payload.object" />
    
        ...
    As a work-around for (2), defining the inbound gateway without using the si-rmi namespace support appears to work, e.g.:
    Code:
        <bean id="rmiInboundGateway" class="org.springframework.integration.rmi.RmiInboundGateway">
            <property name="requestChannel" ref="rmiInboundChannel"/>
            <property name="errorChannel" ref="rmiErrorChannel"/>
            <property name="registryPort" value="${rmi.registry.port:0}"/>
        </bean>  
    
        <si:transformer input-channel="rmiErrorChannel" expression="new java.security.GuardedObject(payload, null)"/>
    instead of (syntactically incorrect as per the SI-RMI 2.2 XML schema)

    Code:
         <si-rmi:inbound-gateway id="rmiInboundGateway" request-channel="rmiInboundChannel" 
              errorChannel="rmiErrorChannel" registry-port="${rmi.registry.port:0}" />
    Are these known issues? Am I going about this the wrong way? Thoughts?

    Thanks,

  • #2
    The RMI gateways are really a special case. The general idea (much like RMI in general) is if there is a remote exception, it gets propagated back to the caller and the general expectation is that you have error handling on the client side (which would depend on what was upstream of the outbound gateway).

    However, as you have discovered, this limitation is in the namespace only and you can declare the gateway using traditional <bean/> syntax; this is particularly easy in this case because simpler components such as this require no "hidden" wiring in the namespace handler.

    I see no reason that we can't add an error-channel to the schema in this case so please go ahead and open an 'improvement' JIRA issue; thanks.

    In the meantime, your work around is fine (and does exactly what the namespace parser will do).

    Comment


    • #3
      Originally posted by Gary Russell View Post
      The RMI gateways are really a special case. The general idea (much like RMI in general) is if there is a remote exception, it gets propagated back to the caller and the general expectation is that you have error handling on the client side (which would depend on what was upstream of the outbound gateway).
      ...
      That's where issue #1 comes into play: the exception propagates just fine, but RmiOutboundGateway's exception handling always ignores the header "errorChannel" of the outgoing message. Instead, all exceptions are routed to the special "errorChannel". I think the intention of the code is (or should be) to first check the "errorChannel" header, and only if the header is missing, route to the default error channel.

      Originally posted by Gary Russell View Post
      ...
      However, as you have discovered, this limitation is in the namespace only and you can declare the gateway using traditional <bean/> syntax; this is particularly easy in this case because simpler components such as this require no "hidden" wiring in the namespace handler.

      I see no reason that we can't add an error-channel to the schema in this case so please go ahead and open an 'improvement' JIRA issue; thanks.

      In the meantime, your work around is fine (and does exactly what the namespace parser will do).
      Will do, thanks Gary.

      Comment

      Working...
      X