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 voidassertTopic(java.lang.String topic)Validate that a topic is suitably set up for the messaging implementationjava.lang.StringassignTo(long offset)Create assign String to feed into poller based on a given offset.java.lang.StringassignTo(Reset reset, long relativeOffset)Get assign String to feed into createPoller based on either earliest or latest and a relative offset.java.io.CloseablecreatePoller(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.CloseablecreatePoller(java.lang.String topicName, Reset reset, HandlerAdapter<?>... adapters)<T> MessageSender<T>createSender(java.lang.String topic)Create sender for a specific topicjava.net.URIgetServerUri()Return the uri of the messaging system backend.longretrieveOffset(java.lang.String topicName, Reset reset)Retrieve earliest or latest offset for a topic
-
Method Details
-
createSender
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 topicreset- fallback in case no assign is given or the assigned offset not validassign- opaque implementation dependent assign string (can be null)adapters- list of listener adapters- Returns:
- closeable handle of the poller
-
assertTopic
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
Retrieve earliest or latest offset for a topic- Parameters:
topicName- name of the topicreset- 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
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 pointrelativeOffset- 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
-