To learn EventStoreDB I wrote a simple java test case as following that reads events from a system built-in projection such as “$streams”.
@Test
public void should_read_event_type_from_projection() throws Exception {
List resolvedEvents = client.streams()
.readStream("$streams")
.fromStart()
.resolveLinks()
.readThrough()
.get()
.getEvents();
resolvedEvents.forEach( x-> {
System.out.println("Original event id: " + x.getOriginalEvent().getEventId());
System.out.println("Original event type: " + x.getOriginalEvent().getEventType());
System.out.println("EventType: " + x.getEvent().getEventType());
System.out.println("Link : " + x.getLink());
System.out.println();
}
);
}
When using db-client-java version 0.5 it products the following outputs which contain correct EventType.
Original event id: 6ca75993-e453-470c-ba56-82ad83d92ef7
Original event type: $>
EventType: ntut.csie.sslab.account.users.command.entity.UserEvents$UserRegistered
Link : com.eventstore.dbclient.RecordedEvent@32811494
But when I used the latest db-client-java version 0.6 and revised the test case accordingly as following:
@Test
public void should_read_event_type_from_projection() throws Exception {
ReadStreamOptions options = ReadStreamOptions.get()
.resolveLinkTos()
.forwards()
.fromStart();
List<ResolvedEvent> resolvedEvents = client
.readStream("$streams", options)
.get()
.getEvents();
resolvedEvents.forEach( x-> {
System.out.println("Original event id: " + x.getOriginalEvent().getEventId());
System.out.println("Original event type: " + x.getOriginalEvent().getEventType());
System.out.println("EventType: " + x.getEvent().getEventType());
System.out.println("Link : " + x.getLink());
System.out.println();
}
);
}
The EventType was missing. Any ideas?
Original event id: 6ca75993-e453-470c-ba56-82ad83d92ef7
Original event type: $>
EventType: $>
Link : null
Note that the EventStoreDB was pull from docker with the following command:
docker run --name esdb-node -it -p 2113:2113 -p 1113:1113
eventstore/eventstore:latest --insecure --run-projections=All
–enable-external-tcp --enable-atom-pub-over-http
Thanks,
Teddy