Most of your questions are covered in repository readme. It's always advisable to read the docs before trying to run any app.
As @umbrel and @sui mentioned, you can utilize standard SDK payments streaming for the simplest case. However, you'll have to write tons of code if you need guaranteed event notifications.
For example, let's consider that you are building a payment processor or an anchor. Probably you need to track transaction memo
values and maybe some other operations (like trades) for your account. It's not possible with /payments
endpoint. You'll end up tracking transactions and parsing raw XDR to retrieve operations. And what if someone sent you a payment when you were rolling an update? Or maybe your server suddenly restarted. You'll miss the payment notification, and a user will be frustrated. Of course, it's possible to avoid this. You just need to store the cursor somewhere, bulk load transactions on application start, and switch to live stream tracking once you processed the history.
I've implemented the same code for different projects more than once, and it was almost identical. Therefore, I decided to create a unified solution that works as a micro-service and allows to forget about all the complexity of reliable notifications streaming.
All you have to do is to deploy it, start the app, and subscribe to the desired notifications. The interaction with the notifier is handled by HTTP API. Once the subscription is created, it will automatically send POST requests for all operations that match your criteria to the endpoint you specified.
Instead of coding each case by yourself, you can create a page or HTTP handler that will receive the notifications. The subscription filter parameters allow you to build intricate filters conditions, like "notify me when account GABU...KPH7 receives a payment in MOBI tokens with memo 34567", or simply grab operations specific operations by type.
With the notifier you can relax and upgrade your application whenever you like. Once it is up, the notifier will continue to send the notifications from that exact point and strictly adhere to the operations order. Restarted the notifier server itself? No problem, you won't miss an operation in any case.
The database is used internally to store cursors and subscription parameters. Users are not supposed to query it directly. To make it work, you need to register register new subscription, either from your application or simply from the console. For example, to track PAYMENT, PATH_PAYMENT, and CREATE_ACCOUNT operations
curl -X POST -d '{"operation_types":[0,1,2], "reaction_url": "http://my-server/payments-handler"}' -H "Content-Type: application/json" http://notifier-server-ip/api/subscription
And answers to your questions:
I want a notification on whenever a payment is received (in the network - not a particular account). Is that possible?
Yes, just specify what type of operations you need without filtering by account
. By the way, an account can receive funds as a result of a PAYMENT, PATH_PAYMENT, CREATE_ACCOUNT, and MERGE_ACCOUNT operations.
What is mongodb used for?
To store auxiliary data and ensure that temporary service (the notifier, subscriber, or both) disruptions won't affect the notifications.
What does maxActiveSubscriptions means?
The maxActiveSubscriptions
parameter specifies how many subscriptions you want to be handled by a single Notifier server. You can increase this parameter if you are running it on the adequate hardware. I tested the service with as much as 10,000 concurrent subscriptions.