-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC not working: What I am doing wrong? Is there an example of its implementation? #186
Comments
Maybe I got your question wrong, but if you trying to send back a result from the rpc call, you could use We do it like this:
|
@manuel-reil, thanks for answering to my question. Actually, I have a microservice that is trying to do an RPC request, via RabbitMQ, and then consume the result that comes back, via RabbitMQ. Based on your feedback, I guess my RPC request was wrong because I was using publish() instead of request(). Am I correct? Also, based on your feedback, I don't need to implement a consumer since request() is going to wait for the return of the result of the RPC request and put it into the chain .then((final) -> ...) |
@acarlstein you are correct. You want request() not publish() for rpc. Under the covers during connection a unique rpc queue is automatically made for you to act as the listener queue to handle the return messages and abstracted to the promise level for ease of use. The rpc request uses the replyTo header that is added during the request() call in order to send it back the the right service that made the rpc request originally. |
I figured out the issue. In the topology, when creating the exchange, I needed to add 'subscribe:true' property since the queue was already created but used as publish instead of request. Thanks anyways for the feedback. I appreciate it. |
Ah yes, the old |
I am having an issue with this as well. following your exact example above...
I am ale to see that my consumer (a java process ) is responding and that there is a message in the temporary queue, but 'received message' is never logged. When I turn on
The use of |
@jtsampson can you provide a sample of the message coming back from the java consumer which is replying on the |
@zlintz , Thanks for getting back to me! [aside] For sake of this discussion, and if it matters, the REQUESTER is a node app originally on I was pursuing this line of debugging earlier this week to try and determine exactly what the form of the message should be comming back from my RESPONDER but I hadn't gotten around to finishing it up. Here is what I did so far. Using the example code and topology in request.spec.js, and dupmping the
I am guessing that my Java consumer has to respond with similar headers and properties but I am not exactly sure which ones...I tried to set up the minum number of these in my RESPONDER code: channel = rabbitMqManager.createChannel();
Map<String,Object> headers = new HashMap<>();
headers.put("sequence_end", true); // possibly expected by node.js rabbot library
AMQP.BasicProperties props =
new AMQP.BasicProperties.Builder()
.appId("CONSUME_APP") // this is the java consume app name not the rabbot publisher app name
.contentEncoding("UTF-8")
.contentType("application/json")
.correlationId(correlationId) // correlation id sent by publisher from rabbit properties
.type((String)properties.getType()) // possibly expected by node.js rabbot library
.headers(headers).build();
// reply to in this case is 'MACHINE.NAME.PROCESS.NAME'
channel.basicPublish("", replyTo, props, (body.toJSONString().getBytes()));
// thisgoes to the default exchange Above I am assumung (possibly wrongly) that I do not need to have the RESPONDER reply with any of the properties that are
Hopefully I am on the right track. Do you know exactly which properties and headers I need? |
Thanks for the run down, I will try this in my code, should take about a day or so to try out.. If that works I will definately be back for details, and I can certainly add a pull request for added documentation. |
@jtsampson any update? |
Sorry for the late reply. Yes, this does solve my issue perfectly. Additionally, PM'ed @acarlstein and this was actually the solution to his problem as well. You can close this issue. |
Solution was also posted here: #76 |
That makes sense why this problem seemed so familiar. I helped @fifthfloorsoftware with this back then |
Greetings,
Will you help me?
I apologize to bother but I am having troubles implementing RPC correctly.
Perhaps someone can point out what I am doing wrong in the code since I couldn't find in the documentation a full example on how to implemented.
Thanks for your time and the creation of this package.
The text was updated successfully, but these errors were encountered: