Skip to content

a few variations of publish-subscribe Design pattern (also known as Observer or Listener)

Notifications You must be signed in to change notification settings

loliksamuel/DP_Publish_Subscribe

Repository files navigation

DP Publish Subscribe

What is pattern publish subscribe (also known as Observer or Listener)?

Publishers are the entities who create/publish a message on a header. Subscribers/listeners/observers are the entities who subscribe to a messages on a header.

In a header based Publish-Subscribe pattern, Publishers tag each message with the a header instead of referencing specific Subscribers. Messaging system then sends the message to all Subscribers who have asked to receive messages on that header.

Publishers only concern themselves with creating the original message and can leave the task of servicing the Subscribers to the messaging infrastructure (this is where pattern comes into picture).

Image result for publish subscribe broker architecture

see other reactive streams projects (build with functional pipeline & lazy evaluation):

public interface Publisher<T> {
    public void subscribe(Subscriber<? super T> s);
}
public interface Subscriber<T> {//with 3 channels
     public void onSubscribe(Subscription s);
     public void onNext(T t);//data
     public void onComplete();//all finished successfully
     public void onError(Throwable t);//to deal with exceptions
 }
 public interface Subscription {
    public void request(long n);//back pressure support
    public void cancel();
}
public interface Processor<T, R> extends Subscriber<T>, Publisher<R> {
}

About

a few variations of publish-subscribe Design pattern (also known as Observer or Listener)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages