You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use this library to do RPC style calls over STOMP to RabbitMQ.
However, it appears that this library doesn't properly support the automatic subscriptions created by a SEND frame containing the reply-to header. I believe ActiveMQ also provides similar functionality in their STOMP adapter.
For a detailed overview of how this works in RabbitMQ see: https://www.rabbitmq.com/stomp.html, under the the heading: Temp Queue Destinations
Here is a brief description of the problem with an example:
I want to use STOMP to send a message from a client to a server, and receive a response from that server. The steps are:
RPC server subscribes to receive messages from the client with this header:
{
destination: '/queue/test'
}
RPC client sends a message using the following header. The broker creates an exclusive, temporary, queue with an opaque name, and automatically subscribes the client to this queue.
I've tried manually creating a subscription with /temp-queue/test as the subscription id, but this is explicitly disallowed by the broker and results in a broker error that also destroys the client.
Would it be possible to change this library to support this use case? I'm not 100% sure what the API would look like.
One possibility would be to provide an onReply function in the options when calling Client#send. This could automatically register a subscription for the reply with the client, where subId === reply-to header. The handler can then be called once with the reply message, and the subscription removed automatically by the Client. This would be similar to the way message receipts work.
var options = {
replyTo: '/temp-queue/test', // automatically adds reply-to to header, like receipts?
onReply: function(message) {
// handle the reply here
}
}
client.send(headers, [options])
Open to ideas, and can probably help with a PR.
The text was updated successfully, but these errors were encountered:
The stompit library has supported RabbitMQ temp queue destinations since v0.22.0, but I agree with you that the library doesn't appear to support this feature, as the required method to use is undocumented and there's no relevant code example provided.
Automatic subscriptions created by a broker can be registered with the client by calling the Client#setImplicitSubscription method. This method should only be called once for each temporary queue destination you define. Automatic subscriptions cannot be cancelled and exist until the client disconnects.
In your example you would call this alternative subscription method once before or immediately after the first send, like for example:
client.setImplicitSubscription('/temp-queue/test','auto',function(error,message){// find and call the reply callback});
The second argument must have value of 'auto' to match the ack mode set by RabbitMQ.
When sending a request include the reply-to header in your send headers:
The stompit library cannot provide a request/response API useful for RPC. The problems of binding a reply callback to a request and how to encode/decode a request id in a message is for the user or another library to solve.
I'm trying to use this library to do RPC style calls over STOMP to RabbitMQ.
However, it appears that this library doesn't properly support the automatic subscriptions created by a SEND frame containing the
reply-to
header. I believe ActiveMQ also provides similar functionality in their STOMP adapter.For a detailed overview of how this works in RabbitMQ see: https://www.rabbitmq.com/stomp.html, under the the heading: Temp Queue Destinations
Here is a brief description of the problem with an example:
I want to use STOMP to send a message from a client to a server, and receive a response from that server. The steps are:
At this point the node Client library is destroyed and raises the following error:
Because there is no registered subscription for that id in the client (it was registered automatically by the broker). This happens here:
https://github.com/gdaws/node-stomp/blob/master/lib/Client.js#L403-L410
I've tried manually creating a subscription with
/temp-queue/test
as the subscription id, but this is explicitly disallowed by the broker and results in a broker error that also destroys the client.Would it be possible to change this library to support this use case? I'm not 100% sure what the API would look like.
One possibility would be to provide an onReply function in the options when calling
Client#send
. This could automatically register a subscription for the reply with the client, wheresubId === reply-to
header. The handler can then be called once with the reply message, and the subscription removed automatically by theClient
. This would be similar to the way message receipts work.Open to ideas, and can probably help with a PR.
The text was updated successfully, but these errors were encountered: