src/main/java/me/paulbares/subscription/ApproverWorkflowRegistrar.java
public void publish(Notification notification, Set<String> users, Set<String> groups, boolean isNew) {
    var subscribersByUser = collectSubscribers(users, groups);
    if (!subscribersByUser.isEmpty()) {
      // To keep track of Subscriber for which the notification has been sent.
      // It guarantees the notification will be deliver only once.
      var notified = Collections.newSetFromMap(new ConcurrentHashMap<>());

      List<SendNotificationTask> tasks = new ArrayList<>();
      for (Map.Entry<String, Set<Subscriber<Notification>>> subscribers : subscribersByUser.entrySet()) {
        tasks.add(new SendNotificationTask(subscribers.getKey(),
                notification,
                subscribers.getValue(),
                // Order in the condition does matter here !
                // Only check the id when the notification is new i.e has just been created. If not new, it means
                // the notification has already been sent either during the subscription or via #onCreate()
                s -> (!isNew || notification.getId() > this.lastSubIdBySub.getOrDefault(s, -1L)) && notified.add(s)));
      }

      // Will be done in the common pool. Publish is done in a synchronous way for the time being.
      ForkJoinTask.invokeAll(tasks);
    }
  }
/**
   * Sends the notification to the given users and users belonging to the given groups. The notification will be send
   * only once to each {@link Subscriber}.
   *
   * @param users the users
   * @param groups the groups
   * @param notification the notification to send
   * @param isNew true if the notification is a new one i.e corresponds to a newly created task, false otherwise (task
   * completed)
   */
Sends the notification to the given users and users belonging to the given groups. The notification will be send
only once to each  Subscriber.

@param users the users
@param groups the groups
@param notification the notification to send
@param isNew true if the notification is a new one i.e corresponds to a newly created task, false otherwise (task
completed)
Sends the notification to the given users and users belonging to the given groups . The notification will be send only once to each Subscriber . @param users the users @param groups the groups @param notification the notification to send @param isNew true if the notification is a new one i . e corresponds to a newly created task false otherwise ( task completed )
public void publish(Notification notification, Set<String> users, Set<String> groups, boolean isNew) {
    var subscribersByUser = collectSubscribers(users, groups);
    if (!subscribersByUser.isEmpty()) {
      var notified = Collections.newSetFromMap(new ConcurrentHashMap<>());
      List<SendNotificationTask> tasks = new ArrayList<>();
      for (Map.Entry<String, Set<Subscriber<Notification>>> subscribers : subscribersByUser.entrySet()) {
        tasks.add(new SendNotificationTask(subscribers.getKey(),
                notification,
                subscribers.getValue(),
                s -> (!isNew || notification.getId() > this.lastSubIdBySub.getOrDefault(s, -1L)) && notified.add(s)));
      }
      ForkJoinTask.invokeAll(tasks);
    }
  }
public void publish ( Notification notification , Set < String > users , Set < String > groups , boolean isNew ) { var subscribersByUser = collectSubscribers ( users , groups ) ; if ( ! subscribersByUser . isEmpty ( ) ) { var notified = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ; List < SendNotificationTask > tasks = new ArrayList < > ( ) ; for ( Map . Entry < String , Set < Subscriber < Notification > > > subscribers : subscribersByUser . entrySet ( ) ) { tasks . add ( new SendNotificationTask ( subscribers . getKey ( ) , notification , subscribers . getValue ( ) , s -> ( ! isNew || notification . getId ( ) > this . lastSubIdBySub . getOrDefault ( s , - 1L ) ) && notified . add ( s ) ) ) ; } ForkJoinTask . invokeAll ( tasks ) ; } }
Sends the notification to the given users and users belonging to the given groups.
Sends the notification to the given users and users belonging to the given groups .
// To keep track of Subscriber for which the notification has been sent. // It guarantees the notification will be deliver only once. // Order in the condition does matter here ! // Only check the id when the notification is new i.e has just been created. If not new, it means // the notification has already been sent either during the subscription or via #onCreate() // Will be done in the common pool. Publish is done in a synchronous way for the time being.