Skip to content
Permalink
Browse files
Define the positionToString signature explicitly in the API
  • Loading branch information
tmaret committed Jan 3, 2019
1 parent ad3b813 commit 617b9b520d66e683c7198ecae19251367a9ac43a
Showing 3 changed files with 19 additions and 3 deletions.
@@ -17,12 +17,23 @@
*/
package org.apache.aries.events.api;

import java.io.Serializable;

/**
* Position in a the topic.
* E.g. For a kafka implementation this would be a list of (partition, offset) as we do not support partitions
* this could simply be like an offset.
* TODO How do we provide ordering without being too specific?
*/
public interface Position {
public interface Position extends Serializable {
long getOffset();


/**
* Serialise the position into a {@code String} string.
*
* @see {@link Messaging#positionFromString(String)} for the reverse operation.
* @return the position as a string
*/
String positionToString();
}
@@ -32,7 +32,12 @@ public long getOffset() {
}

@Override
public String toString() {
public String positionToString() {
return Long.toString(offset);
}

@Override
public String toString() {
return positionToString();
}
}
@@ -63,7 +63,7 @@ public void testSend() {
subscriptions.add(messaging.subscribe("test", null, Seek.earliest, callback));
String content = "testcontent";
Position pos = send("test", content);
assertThat(pos.toString(), equalTo("0"));
assertThat(pos.positionToString(), equalTo("0"));

verify(callback, timeout(1000)).accept(messageCaptor.capture());
Received received = messageCaptor.getValue();

0 comments on commit 617b9b5

Please sign in to comment.