Announcement Announcement Module
Collapse
No announcement yet.
GatewayProxyFactoryBean help/extensions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • GatewayProxyFactoryBean help/extensions

    I am currently working on an application which is split into 2 distinct parts. The first part runs as an internal application on a secure network. The second part is an external application which runs in a web hosting environment. The external application can only communicate with the internal application through JMS i.e. a request is made of the external web site which makes one or more method calls which are translated into messages and put onto a JMS queue. Internally the messages are picked up and converted back into method calls and the results of these method calls returned again via JMS to the caller. I would like to use Spring Integration to simplify this process.

    Myself and a colleague have been looking at the available functionality and think that by extending Spring Integration slightly we can achieve what we want by just creating annotated method calls on an interface. The idea is that we would use an extended version of the GatewayProxyFactoryBean for the method calls from the external website and create a similar InboundGatewayProxyFactoryBean to handle the internal side of the messaging.

    What we think we need to do in the extended GatewayProxyFactoryBean is to map the method name to a header value and create a Map containing all the arguments to the method which would be the payload of the Message. So for the following method call:-

    public interface MyInterface {

    @Gateway
    Result myMethod(@MessageMapping("payload.param1") Integer param1,
    @MessageMapping("payload.param2") String param2 ....);

    }

    This would create a Header call "method" with the value "myMethod" and create a Map containing 2 entries "param1" and "param2" which would be the payload of the message.

    Our InboundGatewayProxyFactoryBean would then process the same interface but look for a different annotation at the method level i.e. the interface would be changed to :-

    public interface MyInterface {

    @Gateway
    @ServiceActivator(beanRef="myBean")
    Result myMethod(@MessageMapping("payload.param1") Integer param1,
    @MessageMapping("payload.param2") String param2 ....);

    }

    In a similar way to the GatewayProxyFactortyBean, our InboundGatewayProxyFactoryBean would create a Map of appropriately annotated method definitions. The InboundGatewayProxyFactoryBean would then look for the "method" header in any inbound messages it was configured to receive which would be used to lookup the corresponding method definition in the Map of method definitions. From the method definition, it will look for the ServiceActivator annotation and retrieve the beanRef property. This property would be used to identify the Spring configured bean which will be used as the target of the method call. In this example it would look for a bean called "myBean" which should contain a method called "myMethod". The parameters would be retrieved from the payload Map and passed to this method (assuming that the number and type etc. all match). The result would then be packaged up as the payload of the return message which the GatewayProxyFactoryBean will process when received.


    Firstly does anyone have any comments on this approach i.e. is this a valid approach or is there anyway it could be improved with existing functionality? Secondly in order to implement the extension to the GatewayProxyFactoryBean we would need to extend the ArgumentArrayMessageMapper to override the "mapArgumentsToMessage" method so that we can perform the parameter Map creation for the payload. Unfortunely though this method is currently private so we would need to create a whole new class which would be very similar to this class. We would also need some mechanism in the GatewayProxyFactoryBean to identify the type of MessageMapper to create when creating the SimpleMessagingGateway that is used for each method call. Finally, is this something we could contribute back to the project i.e. is this something that other people may be interested in?

  • #2
    I think what you need is closely aligned with our plans for 2.0 improvements to the GatewayProxyFactoryBean. We are planning to add the @Payload annotation support (in M2 we're removing @MessageMapping since @Payload/@Header/@Headers should handle all cases and are easier to understand).

    Can you raise an issue in JIRA? I don't think we have one for this exact feature - even though this idea is most definitely on the roadmap.

    This issue might be somewhat relevant as well (feel free to link this to the new one):
    http://jira.springframework.org/browse/INT-670

    Thanks,
    Mark

    Comment


    • #3
      I meant to include this relevant issue as well:
      http://jira.springframework.org/browse/INT-851

      Comment


      • #4
        I have created 2 jira issues, one for the extension of the GatewayProxyFactoryBean (http://jira.springframework.org/browse/INT-882) and one for a new InboundGatewayProxyFactoryBean(http://jira.springframework.org/browse/INT-883).

        I would be happy to help in the implementation of either of these things but it seems that the InboundGatewayProxyFactoryBean is a fairly isolated piece of work which I could pick up. Are you happy for me to do this?

        Comment

        Working...
        X