Announcement Announcement Module
Collapse
No announcement yet.
Error Handling When Using RMI Inbound/Outbound Gateways Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error Handling When Using RMI Inbound/Outbound Gateways

    I have a question regarding error handling when using an rmi:inbound-gateway.

    I have a server application that receives HTTP messages from clients, does a minor transformation on the incoming payloads to strip out sensitive information, and then forwards the message using an rmi:outbound-gateway to one of several service applications on another machine for processing.

    The processing applications use a thread-pool task executor on the channel connected to the rmi:inbound-gateway, forcing the processing to occur on it's own thread. My understanding was that if I used the task executor, Exceptions that are thrown on the processor would be sent to the errorChannel defined in the processor application. That way I could capture any Exceptions and generate a suitable error response to be returned to the original server that sent the RMI message.

    What seems to be happening is that regardless of the task executor, Exceptions thrown on the processor are caught by the RMI handlers and are propagated directly back to the original server, bypassing the errorChannel entirely.

    Is it possible for me to trap the Exceptions on the processor rather than having them propagate back to the calling server application?

    Here is a simplified version of the configuration stripped down to the relevant components.



    SERVER CONFIG:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:int="http://www.springframework.org/schema/integration"
    	xmlns:int-http="http://www.springframework.org/schema/integration/http"
    	xmlns:int-rmi="http://www.springframework.org/schema/integration/rmi"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="
               http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/integration
               http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
               http://www.springframework.org/schema/integration/http
               http://www.springframework.org/schema/integration/http/spring-integration-http-2.0.xsd
               http://www.springframework.org/schema/integration/rmi
               http://www.springframework.org/schema/integration/rmi/spring-integration-rmi-2.0.xsd">
    
    
    ..... various beans handling incoming HTTP request/response .....
    
    	<int:channel id="processorRmi" />
    	<int-rmi:outbound-gateway id="processorGateway"
    		remote-channel="processorInput" 
    		request-channel="processorRmi"
    		reply-channel="inboundReply"
    		host="localhost" />
    
    </beans>

    PROCESSOR CONFIG
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	 xmlns:rmi="http://www.springframework.org/schema/integration/rmi" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="
               http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/integration/rmi
               http://www.springframework.org/schema/integration/rmi/spring-integration-rmi-2.0.xsd">
    
    	<rmi:inbound-gateway 
    		request-channel="processorInput"
    		expect-reply="true" 
    	/>
    
    	<bean id="wsTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" >
    		<property name="corePoolSize" value="10" />
    		<property name="maxPoolSize" value="20" />
    		<property name="queueCapacity" value="20" />
    	</bean>
    
    	<int:channel id="processorInput">
    		<int:dispatcher task-executor="wsTaskExecutor"/>
    	</int:channel>
    
    	<int:chain input-channel="processorInput" output-channel="responseRouter">
    		... a series of transformers that could throw Exceptions ...
    	</int:chain>
    
    	... routers and other transformers that build responses that could throw exceptions ...
    
    	<int:channel id="errorChannel" />	
    	<int:transformer input-channel="errorChannel" ref="errorHandler">
    
    	... a transformer that builds response messages depending on the exception ...
    
    </bean>

    Thanks in advance.
Working...
X