Interface MessageBroker

All Known Implementing Classes:
InMemoyMessageBroker, NatsMessageBroker

public interface MessageBroker
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handle(String subject, RequestHandler handler)
    Registers a handler for a subject, the handler will receive requests and compute some result.
    void
    publish(String subject, org.bson.Document document)
    Runs blocking.
    org.bson.Document
    request(String subject, org.bson.Document document)
    Runs blocking.
    void
    subscribe(String subject, Consumer<org.bson.Document> consumer)
    subscribes to a subject, consumer may run asynchronously
  • Method Details

    • publish

      void publish(String subject, org.bson.Document document)
      Runs blocking. publishes to the message broker
      Parameters:
      subject - subject to publish to
    • subscribe

      void subscribe(String subject, Consumer<org.bson.Document> consumer)
      subscribes to a subject, consumer may run asynchronously
      Parameters:
      subject - subject to publish to
    • handle

      void handle(String subject, RequestHandler handler)
      Registers a handler for a subject, the handler will receive requests and compute some result. The result is sent back as a reply.
      Parameters:
      subject - subject to publish to
    • request

      org.bson.Document request(String subject, org.bson.Document document)
      Runs blocking. Executes an RPC call: The document is published and this method starts listening for incoming replies. The returned Result holds either a document with the requested data, or an error as a string
      Parameters:
      subject - subject to publish to
      Returns:
      RemoteException if the remote throws an exception while handling the request