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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
assertTopic(String topic)
Validate that a topic is suitably set up for the messaging implementationString
assignTo(long offset)
Create assign String to feed into poller based on a given offset.String
assignTo(Reset reset, long relativeOffset)
Get assign String to feed into createPoller based on either earliest or latest and a relative offset.default Closeable
createPoller(String topicName, Reset reset, String assign, Map<String,String> filterProperties, HandlerAdapter<?>... adapters)
Create a poller which listens to a topic and starts at a given reset or assigned offset.Closeable
createPoller(String topicName, Reset reset, String assign, HandlerAdapter<?>... adapters)
Create a poller which listens to a topic and starts at a given reset or assigned offset.default Closeable
createPoller(String topicName, Reset reset, HandlerAdapter<?>... adapters)
<T> MessageSender<T>
createSender(String topic)
Create sender for a specific topicURI
getServerUri()
Return the uri of the messaging system backend.long
retrieveOffset(String topicName, Reset reset)
Retrieve earliest or latest offset for a topic
-
-
-
Method Detail
-
createSender
<T> MessageSender<T> createSender(String topic)
Create sender for a specific topic- Type Parameters:
T
- type of the message- Parameters:
topic
- topic name- Returns:
- sender
-
createPoller
default Closeable createPoller(String topicName, Reset reset, HandlerAdapter<?>... adapters)
-
createPoller
Closeable createPoller(String topicName, Reset reset, 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
-
createPoller
default Closeable createPoller(String topicName, Reset reset, String assign, Map<String,String> filterProperties, 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)filterProperties
- List of properties used to filter the topic messages. Only messages that match all filterProperties keys and values will be received.adapters
- list of listener adapters- Returns:
- closeable handle of the poller
-
assertTopic
void assertTopic(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(String topicName, Reset reset)
Retrieve earliest or latest offset for a topic- Parameters:
topicName
- name of the topicreset
- latest or earliest- Returns:
- offset
-
assignTo
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
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 pointrelativeOffset
- relative offset- Returns:
- assign String
-
getServerUri
URI getServerUri()
Return the uri of the messaging system backend. The uri must be unique regarding the validity of per topic offsets.- Returns:
- uri
-
-