Webhooks
Hey there,
I'm currently developing an application and I'm using Neon for authentication storage and MongoDB for data storage. I'm facing a challenge where I need to retrieve the user ID from Neon.tech and connect it with MongoDB seamlessly.
After some research, I believe the best solution for this integration is through webhooks. However, I'm seeking guidance on how to effectively implement this.
Could you provide insights or resources on how to set up webhooks to fetch user IDs from Neon.tech and utilize them to interact with MongoDB?
Any help or suggestions would be greatly appreciated!
Thanks in advance.
3 Replies
flat-fuchsia•2y ago
There are probably a few different approaches. Without logical replication or FDW, you could use an outbox pattern.
Basically, when you update a row in Postgres do it as part of a transaction that also writes a record to an outbox table. This is basically an event record. Pseudocode:
BEGIN TRANSACTION
CRUD ON USER
INSERT EVENT TO OUTBOX
COMMIT
Have a Go/Node/Java/Python application that checks that table for new entries and POST a webhook wherever you need, or directly update MongoDB whenever a new record is found in the outbox table.
flat-fuchsia•2y ago
microservices.io
Microservices Pattern: Pattern: Transactional outbox
First, write the message/event to a database OUTBOX table as part of the transaction that updates business objects, and then publish it to a message broker.
flat-fuchsia•2y ago
You could use River or Graphile Worker to act as the “relay”