Interface MessagingProvider


public interface MessagingProvider
Messaging abstraction for a journal based messaging like Apache Kafka. Messages are represented as json serialisable java classes. The API assumes that each MessagingProvider is mapped to exactly one partition, so positions in a topic can be represented as a single long offset.
  • Method Summary

    Modifier and Type Method Description
    void assertTopic​(java.lang.String topic)
    Validate that a topic is suitably set up for the messaging implementation
    java.lang.String assignTo​(long offset)
    Create assign String to feed into poller based on a given offset.
    java.lang.String assignTo​(Reset reset, long relativeOffset)
    Get assign String to feed into createPoller based on either earliest or latest and a relative offset.
    java.io.Closeable createPoller​(java.lang.String topicName, Reset reset, java.lang.String assign, HandlerAdapter<?>... adapters)
    Create a poller which listens to a topic and starts at a given reset or assigned offset.
    default java.io.Closeable createPoller​(java.lang.String topicName, Reset reset, HandlerAdapter<?>... adapters)  
    <T> MessageSender<T> createSender​(java.lang.String topic)
    Create sender for a specific topic
    java.net.URI getServerUri()
    Return the uri of the messaging system backend.
    long retrieveOffset​(java.lang.String topicName, Reset reset)
    Retrieve earliest or latest offset for a topic
  • Method Details

    • createSender

      <T> MessageSender<T> createSender​(java.lang.String topic)
      Create sender for a specific topic
      Type Parameters:
      T - type of the message
      Parameters:
      topic - topic name
      Returns:
      sender
    • createPoller

      default java.io.Closeable createPoller​(java.lang.String topicName, Reset reset, HandlerAdapter<?>... adapters)
    • createPoller

      java.io.Closeable createPoller​(java.lang.String topicName, Reset reset, java.lang.String assign, HandlerAdapter<?>... adapters)
      Create a poller which listens to a topic and starts at a given reset or assigned offset.
      Parameters:
      topicName - name of the topic
      reset - fallback in case no assign is given or the assigned offset not valid
      assign - opaque implementation dependent assign string (can be null)
      adapters - list of listener adapters
      Returns:
      closeable handle of the poller
    • assertTopic

      void assertTopic​(java.lang.String topic) throws MessagingException
      Validate that a topic is suitably set up for the messaging implementation
      Parameters:
      topic - topic name
      Throws:
      MessagingException - exception in case the topic is not suitable
    • retrieveOffset

      long retrieveOffset​(java.lang.String topicName, Reset reset)
      Retrieve earliest or latest offset for a topic
      Parameters:
      topicName - name of the topic
      reset - latest or earliest
      Returns:
      offset
    • assignTo

      java.lang.String assignTo​(long offset)
      Create assign String to feed into poller based on a given offset. The inner format of the assign string is implementation specific.
      Parameters:
      offset -
      Returns:
      assign String
    • assignTo

      java.lang.String assignTo​(Reset reset, long relativeOffset)
      Get assign String to feed into createPoller based on either earliest or latest and a relative offset. The inner format of the assign string is implementation specific.
      Parameters:
      reset - reference point
      relativeOffset - relative offset
      Returns:
      assign String
    • getServerUri

      java.net.URI getServerUri()
      Return the uri of the messaging system backend. The uri must be unique regarding the validity of per topic offsets.
      Returns:
      uri