Unable to access next revision


We are currently at client version 3.0.2.

When performing an appendToStream, we get a write result back which contains a nextExpectedVersion, which is a long. The caller then receives this version, and we regularly use it to poll the read model to check when it’s available.

I have been experimenting a bit with client version 4.1.1 to see what changes need to be made. I noticed there isn’t a nextExpectedVersion anymore.

Instead there’s a nextExpectedRevision, but this is an abstract class of ExpectedRevision. One of the subclasses is a SpecificExpectedRevision, but that isn’t public, and so we can’t extract the version from that.

From 4.1.1, how do I access the next expected version?


Yeah, it wasn’t a great decision. @oskar.dudycz had to make this to work around the issue.

 //This ugly hack is needed as ESDB Java client from v4 doesn't allow to access or serialise version in an elegant manner
   private ETag toETag(ExpectedRevision nextExpectedRevision) throws NoSuchFieldException, IllegalAccessException {
     var field = nextExpectedRevision.getClass().getDeclaredField("version");

     return ETag.weak(field.get(nextExpectedRevision));

It would be nice if we get an issue created in the client repo to address it.

OK thank you.

I’ve now created a ticket on the repo: https://github.com/EventStore/EventStoreDB-Client-Java/issues/228


You can find that PR that now exposes ExpectedRevision as a numerical value.

1 Like

Is there a way for me to test it without waiting for a release?

The README mentions snapshot versions being created on every merge, but there doesn’t appear to be any versions since 3.1.0: https://oss.sonatype.org/content/repositories/snapshots/com/eventstore/db-client-java/

Seems you are not looking at the right place: https://central.sonatype.com/artifact/com.eventstore/db-client-java/4.1.1/versions

I can cut a release this week with that feature considering it’s not a breaking change.

Ah OK thanks,

I was trying to extrapolate from the snapshots section in the README: https://github.com/EventStore/EventStoreDB-Client-Java#snapshot-versions

Version 4.2.0 is available on Maven Central: https://central.sonatype.com/artifact/com.eventstore/db-client-java/4.2.0