Announcement Announcement Module
Collapse
No announcement yet.
AMQP and RabbitMQ Server Client model Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AMQP and RabbitMQ Server Client model

    Hi Experts,
    Currently I am planning to use AMQP and RabbitMQ with my projects, I am using virgo osgi container to run my all services(UserManagerService, PaymentService etc).

    Spring webapp running on tomcat 7. I have requirement such as,

    I have some methods to call service(Server) from webapp(Client), Listed methods are

    1) getEmailByUserUUID(UUID)
    2) getEmailByUserID(userName)
    3) listAllUser()

    And I have same listed method in service layer as well. such as
    1) sendEmailByUserUUID(UUID)
    2) sendEmailByUserID(userName)
    3) listAllUser()

    I need to access sendEmailByUserUUID by accessing getEmailByUserUUID from client side. I need those methods to access via USERQUEUE, Is it possible to access each method with routingKey? which is the best approach, Please suggest me to implement a bestpractice.

    Thankyou,

    gopy

  • #2
    Your question is not at all clear; you need to provide much more detail.

    Comment


    • #3
      Hi Gary,
      Thankyou for the reply and sorry for the unclear post.

      Simply says, I have some methods in producer side which are

      1) getEmailByUserUUID(UUID)
      2) getEmailByUserID(userName)
      3) listAllUser()

      and I have some methods in consumer side which are

      1) sendEmailByUserUUID(UUID)
      2) sendEmailByUserID(userName)
      3) listAllUser()

      If i call 'getEmailByUserUUID ' methods i need to get reply from 'sendEmailByUserUUID' as well as 'getEmailByUserID' should get reply from 'sendEmailByUserID' with same QUEUE.

      According to AMQP docs i understood convertSendAndReceive(Consumer side) and receiveAndReply(Producer side) will do the job but i do not know how to configure queue binding for producer and consumer mapping.

      Thank-you in advance

      Gopy

      Comment


      • #4
        It's still not clear what you are trying to do sendEmailByUserID(userName) - what/where is the email content?

        convertSendAndReceive() will just work (it creates a temporary queue for the reply).

        If you want a fixed reply queue for all requests; use a reply listener (http://docs.spring.io/spring-amqp/do...#request-reply).

        Bind the request queue to an exchange with a routing key and on the producer side, send that that exchange with the routing key (or you can just send to the default exchange with the queue name as the routing key - convertSendAndReceive("", "queue", myObject). You will need a separate queue for each request type, but all the replies can share the same reply queue.

        Comment


        • #5
          Ah now i understood why my questions are not clear, Ok let me clear as much as possible this time.

          I have user data in database with userid, username, emailid, contactNumber etc. i have some impl method in service layer to get user related data which are


          1) getEmailIdByUserUUID(UUID)
          2) getEmailIdByUserName(userName)
          3) listAllUser()

          I want to access this method from my webapp controller through RabbitMQ using AMQP,

          I have to use special queue only for user related communications and I have estimated , morethan 1000 request should come through USERQUEUE at a time. So i need to consider that as well.

          Hope you understand now.

          gopy

          Comment


          • #6
            If you can only use one queue for all requests, you will need some glue code in your listener to look at something in the message to decide which method to call.

            Or, you can simply use Spring Remoting over AMQP... http://docs.spring.io/spring-amqp/do....html#remoting where you inject a proxy for the remote service. Again, you can configure the rabbit template to use temporary or a fixed reply queue.

            Comment


            • #7
              Thank you for the reply, I read RPC over AMQP it would help me to call different method from client side. I will implement and let you know about updates.

              Thank you again

              gopy

              Comment


              • #8
                Hi Gary,

                Yes i followed the link (http://docs.spring.io/spring-amqp/do....html#remoting) to create RPC model with AMQP. I have created client(org.springframework.amqp.remoting.client.Am qpProxyFactoryBean) and listener (org.springframework.amqp.remoting.service.AmqpInv okerServiceExporter) bean according to document, I do not know how to send message from client. Do you have any samples to complete this?

                help me to complete my testing application. thankyou in advance

                gopy

                Comment


                • #9
                  See the test cases for examples... https://github.com/spring-projects/s...ts-context.xml

                  and

                  https://github.com/spring-projects/s...tingTests.java

                  Comment


                  • #10
                    yes, thank you. Moreover i want to know the best way to use AmqpTemplate in my application. Lets say i have 5 queues. Is it ok to use one instance of AmqpTemplate for all queues?

                    Comment


                    • #11
                      It's ok to use one; you will have to specify the exchange/routing key on each send...() though.

                      Comment

                      Working...
                      X