benthosdev / benthos

Fancy stream processing made operationally mundane
https://www.benthos.dev
MIT License
7.68k stars 752 forks source link

Add nats_reply_subject to NATS message metadata #2512

Closed Zambito1 closed 1 month ago

Zambito1 commented 1 month ago

This is not an ideal solution to #2232, but this change does make it possible to reply to NATS requests. Just add a NATS output that publishes on the subject ${! metadata("nats_reply_subject") }. Even with the more ideal sync_response implementation, I think this would still be good to have.

Jeffail commented 1 month ago

Hey @Zambito1, LGTM but can you please appease the benevolent DCO bot with git commit --amend -s and then force push?

Zambito1 commented 1 month ago

the DCO bot seems to like me now

ianschenck commented 3 weeks ago

Simply adding a NATS output that ships messages to that subject results in a race between ACKing the message and sending the reply message. NATS overloads the Reply field on msg, and uses it for ACKing/NACKing as well as request-reply, so you randomly will receive either +ACK or the message from the output.

Zambito1 commented 2 weeks ago

Yeah, I ran into this also @ianschenck. This definitely shouldn't be used for REQ/REP in production.