-
Notifications
You must be signed in to change notification settings - Fork 8
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
Customizable reply routing in consumer #36
Comments
Sure, seems reasonable.
…-------- Original Message --------
On Dec 2, 2023, 10:58 AM, Alexander Smirnov wrote:
Hey there!
First of all, big thanks for you work! We really like your library, especially higher-level Consumer/Publisher API.
I want suggest an enhancement for Consumer API: in our application we need to route replies in specific exchanges and this is not possible due the order of Envelope properties in destructuring at line [200](https://github.com/cody-greene/node-rabbitmq-client/blob/8e3a0613e0d0dc01035f0377bf128f32a95ebcd5/src/Consumer.ts#L200) of Consumer. For now we're use monkey patch from example which allow us to config reply function like Publisher.send method and kept default behaviour from documentation.
Do you think this change would be useful for the library?
const
{
Connection
}
=
require
(
'rabbitmq-client'
)
;
const
{
Consumer
}
=
require
(
'rabbitmq-client/lib/Consumer'
)
;
class
ProcessingConsumer
extends
Consumer
{
_makeReplyfn
(
req
)
{
return
(
body
,
envelope
)
=>
{
if
(
!
req
.
replyTo
)
{
throw
new
Error
(
'attempted to reply to a non-RPC message'
)
;
}
return
this
.
_ch
.
basicPublish
(
{
exchange
:
''
,
routingKey
:
req
.
replyTo
,
correlationId
:
req
.
correlationId
,
...
envelope
,
}
,
body
)
;
}
;
}
}
class
ProcessingConnection
extends
Connection
{
createConsumer
(
props
,
cb
)
{
return
new
ProcessingConsumer
(
this
,
props
,
cb
)
;
}
}
exports
.
ProcessingConsumer
=
ProcessingConsumer
;
exports
.
ProcessingConnection
=
ProcessingConnection
;
—
Reply to this email directly, [view it on GitHub](#36), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABQGASZZRVPB5RP2OY63HOLYHN25XAVCNFSM6AAAAABAEGFHOGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZDEMJWGUYDAMA).
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there!
First of all, big thanks for you work! We really like your library, especially higher-level Consumer/Publisher API.
I want suggest an enhancement for Consumer API: in our application we need to route replies in specific exchanges and this is not possible due the order of Envelope properties in destructuring at line 200 of Consumer. For now we're use monkey patch from example which allow us to config reply function like Publisher.send method and kept default behaviour from documentation.
Do you think this change would be useful for the library?
The text was updated successfully, but these errors were encountered: