Deliver message to consumer and expect response in RabbitMQ - rabbitmq

I have a requirement where in (RabbitMQ)server sends the request to the client and client executes the operation and sends the response back to the server.
I would like to know which mechanism to use for this Topic, PubSub, Routing...
Can we create the bi-directional connection like server-client similar to xmpp in rabbit mq, if yes how can we do?
thanks
Lokesh

You can use a Spring AMQP asynchronous consumer with a MessageListenerAdapter to invoke a POJO. See the reference documentation.
If you want more control; use a simple MessageListener and send the reply with a RabbitTemplate.
This test case shows an end-to-end configuration (client side and server side). The client side automatically takes care of setting the correlationId.

Related

Why is AMQP a two-way RPC protocol?

I read the Pika doc, but I am not quite understand why it says "AMQP a two-way RPC protocol, where the client can send requests to the server and the server can send requests to a client...". Can anyone give me an example please ?
Does it mean when we create a exchange.
client sends: exchange.declare
server replies: exchange.declare-ok
Are these two method requests?
In your particular example exchange.declare is client request and exchange.declare-ok is server response.
Though, there are some methods that server can send to client, e.g. basic.deliver, basic.return, connection.blocked (RabbitMQ-specific extension).

WCF duplex channel for inter-process communication

I have system like this:
Windows service (WCF, data/events) <-> Web app <-> Web client
I need simultaneous response for clients requests. I have some events from service for clients too. So duplex channel is the way to go. But I need high throughput, because clients calls simultaneously.
Request/reply approach
In order not to serialize channel requests I need more channels for parallel calls, right? But how to handle callback channel then? Ho to keep it still open for receiving events, even on channel errors?
OneWay approach
On channel should be enough (no waiting for data preparation), but how to link data sent to callback with original request, to be able to compose response for client?
What is the way to go? Thank you.
In a simple case, when a web client sends a request to the web app, and web app (possibly) sends a request(s) to WCF service, there's no need in duplex binding at all.
As for events, raised by the service to be fired in Web client, I'd suggest to use a message broker which supports WebSockets - for example RabbitMQ. It has a plugin compatible with WebSockets and WCF binding.
Putting things together, one can create a RabbitMQ server, which accepts messages from WCF service and sends it to Web client, which subscribes to the event feed from Javascript.

WSO2 ESB - can it support concept with bridging webservice and MQ messages?

is it possible to implement following concept with WSO2 ESB:
http listener for webservices with a method to be called (SOAP)
java routine to process message
same routine to put message to MQ queue Q1
same routine to get answer message from MQ queue Q2
return with processed answered message to webservice caller
or it's better to go with J2EE server and handle messaging part fully through java code?
Regards, Nikola
Well now usecase is much more clear so that we can go ahead and implement it. There are two ways of doing this.
First Approach
Write a Proxy(HTTP to JMS) service which accepts HTTP requests and
place it in JMS Q1 using the jms sender.
Then write another proxy (JMS to JMS), which picks the messages from
JMS Q1, process it and place it in JMS Q2.
Finally create another proxy (JMS to HTTP) to get the message from
JMS Q2 and send it back to the client using the respond mediator.
Second Approach
Create a proxy service (HTTP to JMS) and use store mediator to store the message into JMS Q1.
Create a Forwarding Message Processor to listen to Q1 and pick the message, process it, place it in Q2.
Then create another forwarding message processor to listen to Q2, and send it back to the client using a reply sequence in the message processor.
Choose which ever the way you like and let me know how it goes.
You can use ESB to implement this. But your usecase is not that clear to me. Appreciate if you can explain your usecase in functional perspective. Anyway you have HTTP(S)/JMS listeners and senders with ESB . You can't listen to a SOAP web service using ESB. What you can do is listen to HTTP traffic. Create a proxy that listens to HTTP traffic and send the message to JMS queue Q1 ussing JMS end point. Then write a JMS listener proxy to listen to the answers in Q2. Once it is received you can call the endpoint web service using send or call mediator. This is how I understood your usecase. I have no idea on transformation of data in Q1 and place it in to Q2 due to wired requirements specified above. It looks simple HTTP to JMS switching usecase to me.

Multiple MSMQ communication in WCF

I am using a client server application in which client send request to server in request queue, server receive this request object from queue process it and send response in response queue which is received by client application. I want same functionality in wcf service and client so whether I need to create two different end points for both msmq and if yes than how same client will work with both endpoints.
You should not think of it as strictly a client server application.
You do have a request originator referred to as client and a request processor referred to as Server,
but when thinking WCF- client is the one sending the message, server is the one receiving. Meaning that in WCf terms, at first your client is really a classic "client" and the server is really a classic "server". But when you get to the point after the original request is processed and needs to be sent back- the roles are reversed! the server becomes a WCf client and the client becomes a WCf server.
What this means is that you processes need to expose a separate endpoint for each other. The server listens on a certain EP for incoming messages (requests), and the client listens on a certain EP for incoming messages (responses).
Hope this clarifies things a bit.

WCF service to queue all request

I have a wcf service and handle a lot of client (server document generation). This service should receive a lot of request and should be handle in queue. It also have a callback. (callback will return successfully generated document). I am still using PIA and will implement OpenXML in the future.
Is it wcf msmq is the way to implement this?
Is there any samples might be related? Previously its running in local machine but now want to change it as a so called "Server generated"
WCF MSMQ doesn't support callback directly - it supports only one-way operations. But for example this article discuss how to add this support. With default configuration you can send message back to original sender but it is not a callback. To support responses every client will have to expose queue and pass address of its queue as part of the request to be able to receive the message from the service. More about responses in MSMQ is in MSDN magazine.