Announcement Announcement Module
Collapse
No announcement yet.
Channel topology for service-activated service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Channel topology for service-activated service

    I have a gateway service that has multiple methods:
    HTML Code:
    <int:gateway id="gatewayService" service-interface="contracts.ServiceInterface" default-request-channel="requestChannel" default-reply-channel="replyChannel">
        <int:method name="method1"/>
        <int:method name="method2"/>
        <int:method name="method3"/>
        <int:method name="method4"/>
    </int:gateway>
    On the receiving end, I am listening for requests on requestChannel and activating a service handler:
    HTML Code:
    <bean id="gatewayHandler" class="handler.GatewayImpl"/>
    <int:service-activator input-channel="requestChannel" ref="gatewayHandler" method="handleReply"/>
    On the service-activator, I want to have a distinct handler method for each complementary method in the outbound gateway. How can I do that? If that is not how it should be handled, what method is prescribed?

    I could create a request and reply channel for each method, but that seems excessive. If I did that, would I need to create a distinct queue for each (I'm using amqp and rabbit, which I haven't shown here)?

    Thanks,

    Scott

  • #2
    Well, if you try to think about all you just said in terms of Messaging than you quickly realize that all you trying to accomplish is basic routing based on what method was invoked. Also your based on your description it seems like your use case is very similar to the LoanBroker sample - https://github.com/SpringSource/spri...ns/loan-broker
    Give it a shot and if you still have questions.

    Comment


    • #3
      Great, Oleg. I'll give that a look. I wasn't sure where to look--at first I was thinking I needed an inbound gateway to reflect the outbound gateway, but couldn't find anything that seemed applicable. Thanks for the reply.
      Scott

      Comment


      • #4
        What I understand after looking at the loan broker application is that there needs to exist a distinct channel per gateway method. So if I have a gateway interface that contains 50 methods, then I need 100 channels, 1 for each method's request and reply?

        Since I use AMQP to adapt these channels, I need to create a distinct queue for each?

        Scott

        Comment


        • #5
          Well, LoanBroker was just to get you started. Now since you looked at it I can tell you that you don't even need 50 methods on the gateway. One will do as long as you have a way of introducing some type of discriminator in the method call and that is easily done with passing some type of unique header
          For example"
          Code:
          public interface MyGateway {
               String echo(String value, @Header("discriminator") String discriminator)
          }
          and than. . .
          Code:
          MyGateway gateway =. . .
          gateway.echo(<whatever you were passing>, "foo")
          gateway.echo(<whatever you were passing>, "bar")
          The 'foo'/'bar' became the discriminators

          Now you can use HeaderValueRouter to route Messages based on the header.

          Comment


          • #6
            I know it's been a couple weeks, but I'm finally to the point of trying this out again. I'm generating my spring integration configuration now using annotation processing with a maven plugin, and I'm trying now to take advantage of the HeaderValueRouter. What stands out to me now is that I really don't want to route to a variety of channels. I have one channel that handles requests for a single service, but that service has a different message for each method call on that service. What I need is to define a service-endpoint that specifies a handler method based on the discriminator.

            So my next question was going to be how to achieve this, but I found this thread and am going to check it out. Thanks for your response earlier.

            Comment


            • #7
              Please don't post the same question on multiple threads.

              Thanks!

              Comment


              • #8
                AMQP adapters have 'mapped-request-headers' and ' mapped-reply-headers' to handle all custom headers

                Comment


                • #9
                  Thanks, Oleg. I deleted my last question because I had the same question on the other thread. With this information my request makes it to the client side and is processed by the appropriate method. This is great news.

                  Comment

                  Working...
                  X