Announcement Announcement Module
No announcement yet.
Gateway questions and sugestions Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gateway questions and sugestions

    I spend the last few days implementing a Gateway and I have a few questions and suggestions.

    Q1) Seeing the example in GatewayProxyFactoryBeanTests, I realised that although there is a Interface for the Gateway, nowhere is to be found a Implementation of that Interface. Why is that? In my use case we need both (Interface and Implementation) which I had to "hand code" myself.

    Q2) How can I access the Gateway properties (request-channel, reply-channel, message-creator, etc...) from within the code? Once I injected the Gateway as my Interface in my code, I can do something like

    Advised gat = (Advised) gateway;
    DefaultPointcutAdvisor d = (DefaultPointcutAdvisor)gat.getAdvisors()[0];
    but I have then the setRequestChannel etc. but not the corresponding gets. I do need to access the Channels, and now I'm doing it by injecting manually alongside the Gateway.

    Q3) If I understand correctly, Gateway is only used to "fire&forget" messages and synchronous Request/Reply messages. Is there a way to extend this to support other kind of messaging (asynchronous, with correlationId, synchronous-that-fall-down-to-assyncrounous-with-correlationId-on-time-out, etc...)?

    S1) Ways to provide access to what I just said in Q2, if there aren't any that I don't know about.

    S2) Ways to implement Q3.

    S3) When I invoke a method of my Interface thru the Gateway, it will be useful that the invoked method signature goes in the Headers of the wrapper message, like a "internal.header.invokedmethod" key. I implemented that but it was a pain in the ***.

    S4) Following Q1 and S3, and supposing there aren't any methods to do that that I'm unaware of, it will be interesting to provide a way to map the Interface method call to the same (implemented) method of a service activator handler. Again, I implemented my own version, but again painfully...

    S5) Add a "errorChannel" to the Gateway, to avoid the Dead Letter problem.

    Overall, I'm very happy with the way things are turning, thanks for your excellent work, I wish I could contribute more.
    Last edited by amsmota; Aug 28th, 2008, 07:41 AM.

  • #2
    I think I would recommend against using the gateway in your case. The main purpose of the gateway is to generate a proxy (the implementation) behind the scenes so that all of the messaging components (channels and messages themselves) are hidden from the user. This works well when you simply want to invoke a method that triggers a simple send and/or receive across MessageChannels. In that sense, the idea behind gateway is similar to that of other Spring ProxyFactoryBeans (RMI, HttpInvoker, etc).

    In your case, however, you clearly do want to be aware of the Message and the MessageChannels. So, perhaps you should just create your own "client" object and use dependency injection to provide the channels. Then, use the MessageBuilder to create the Messages. For simple send and receive operations, you can also use the MessageExchangeTemplate. There is nothing wrong with that approach either.

    In general, anytime you find yourself accessing the target object of a proxy, it is a good sign that you don't need the proxy. Its purpose is to hide the details, but in your case, you want to know the details, and thus the proxy is getting in the way.

    Hope that helps.



    • #3
      But i like the gateway ... I think it gives me what I need, i.e. a way for developers to define their services without even think about the messaging platform. Basically, I want then to write code like (using Jersey annotations now)

      public interface ITestService {
      	String sayHello(@PathParam("name")String name, @PathParam("delay")int delay);
      	String sayHello(@PathParam("name")String name);
      public class TestService implements ITestService{
      	public String sayHello(final String name, int delay) {
      		try {
      			Thread.sleep(delay *1000);
      		} catch (InterruptedException e) {
      			return String.format("Too much time, sorry");
      		return String.format("Hello %s (after %s seconds)!", name, delay);
      	public String sayHello(final String name) {
      		return String.format("Hello %s!", name);
      and then just simply assign those to the gateway and service-activator respectively.

      I have this working now, I just want to refine the all thing. Hence my suggestions. Now I see that Q2/S1 can be implemented with a MessageSelector, S2 and S5 I already implemented, but Q3/S2 and S5 will be important for my goal.



      • #4
        For now, we dropped all of our questions regarding the assync messaging and we'll live with the Fire & Forget and the Synch yokes.

        However we are still concerned about the Error Channel and the Dead Letter Channel. Have you guys something in mind to implement them in Gateway, or do you have some kind of strategy to deal with this?

        If not it's ok, I just implement them myself, but I'll like to do it in a "compatible" way with the "big picture" that I'm probably not seeing in their full extension.