ElasticSearch Event Listener

Sandor Mezil :

My target is to build an MQTT publish/subscribe like service by only exploiting Elasticsearch.

The case study scenario I would like to implement is this:

  1. User A create a message (document) inside the Elasticsearch index
  2. User B is warned and updated about the new message on the index.

I'm using plain java clients, since in Android I can't use the High Level Elastic search client. I have everything that allow me to send and read documents from the ES index, but I would like to find the best way to implement a subscription service for User B, without forcing him to poll for updates every few seconds.

About this I don't know where to start. I didn't find any trigger/websocket service available in ES. Please help with some ideas / documentation.

a-ro :

You can use Elastic Search Watcher to trigger an action when a specific condition is met. An example use case is if you ingest live data from Meetup.com in your Elastic Search instance and want to receive email notifications about events you might be interested in.

For your specific use case, you could create a watch that triggers when User A adds a document in the index. The watch action could be to send an email to User B or call your own API in charge of notifying all users that have subscribed to User A (see Webhook action).

I haven't tried it myself, but this seems like a good place to start.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=106935&siteId=1