server sent events - Notification using jersey 2.8 - To notify to specific group of users -


we using jersey 2.8 implementing restful webservice in our application.

so same using serversentevent (sse) notify user occurrence of event in server side.

we found there 2 ways of implementing same. 1. notification. 2. broadcast.

for both type registered user gets notification.

notification: user registers specific event same new thread created , client notified in thread.

problem using notification approach: in case of notification, have keep on waiting event occur(by polling occurrence of event in thread infinitely).

broadcast: in order rid infinitely polling event used broadcast. here, user registers specific event, , event occurs can published client.

problem broadcast approach: in case if want notify specific group of users not getting how should implemented.

for instance: in case of facebook notification, person x posts status, there following categories of persons, y - has liked post. z - has commented on post. q - friend of x has neither commented nor liked.

so when person x posts status update, person z comment on registered event (i.e. if else comments on post z notified, y not notified).

how achieve such kind of notification using jersey 2.8 sse?

i got following way of implementing same,

  1. i wrote wrapper broadcaster, accepts requests, maintains map, contains map of broadcaster respective clients notified.
    ex: using same example in question, persons x's post when person z comments on post, 2 services invoked,
    • one posting comment.
    • other registering notification. in map have entry commentid mapped broadcaster. , user z added list of clients broadcasted.
  2. whenever new event occurs, broadcaster need broadcast map, , broadcast broadcaster.
    ex: when else comments on post, map corresponding broadcaster using commentid , broadcast message clients.

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -