- Node.JS
- Some AMQP server (tested only with RabbitMQ, but theoretically can work with others)
- Posgresql with observer db installed there
git clone https://github.com/maprox/observer-job-geofence-presence.git
cd observer-job-geofence-presence
npm install
npm start
npm run eslint && npm test
-
This job listens for new packets coming from the Message Broker (RabbitMQ in our case) in form of
{ "id": 290129, }
where 290129
in the example above is a packet id which has been recently
received and added to the observer database.
-
When such packet received, the job loads all available geofences (should be refactored when number of geofences exceeds 10,000) and
-
Over each geofence it checks if the packet is in or not, and updates database records accordingly.
-
Finally it sends original message to notification channel (to proceed with geofence entrance/leaving notifications).
{ "id": 290129, }
- AMQP_CONNECTION [amqp://guest:guest@127.0.0.1//] - AMQP connection string
- AMQP_EXCHANGE - exchange name in AMQP server.
- AMQP_QUEUE_NAME - AMQP queue name to listen for messages
- AMQP_QUEUE_ROUTING_KEY - Routing key for the queue
- AMQP_NOTIFICATION_EXCHANGE - AMQP exchange for sending notifications
- AMQP_NOTIFICATION_ROUTING_KEY - Routing key for sending notifications
- AMQP_MESSAGES_COUNT_LIMIT - Limit messages count consumed by the channel at once
- PGHOST - Postgres host
- PGDATABASE - Postgres database
- PGUSER - Postgres username
- PGPASSWORD - Postgres password