Skip to content

Commit

Permalink
Change example to use reader group. (pravega#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaitchuck authored Feb 8, 2017
1 parent a44690c commit 8ab6861
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,37 @@

import com.emc.pravega.stream.EventStreamReader;
import com.emc.pravega.stream.ReaderConfig;
import com.emc.pravega.stream.ReaderGroupConfig;
import com.emc.pravega.stream.impl.JavaSerializer;
import com.emc.pravega.stream.mock.MockStreamManager;

import java.util.Collections;
import java.util.UUID;

import lombok.Cleanup;

public class StartReader {

private static final String READER_GROUP = "ExampleReaderGroup";

public static void main(String[] args) throws Exception {
@Cleanup
MockStreamManager streamManager = new MockStreamManager(StartLocalService.SCOPE,
"localhost",
StartLocalService.PORT);
streamManager.createStream(StartLocalService.STREAM_NAME, null);
@Cleanup
EventStreamReader<String> reader = streamManager.getClientFactory().createReader(StartLocalService.STREAM_NAME,
new JavaSerializer<>(),
new ReaderConfig(),
streamManager.getInitialPosition(StartLocalService.STREAM_NAME));
streamManager.createReaderGroup(READER_GROUP,
ReaderGroupConfig.builder().startingTime(0).build(),
Collections.singletonList(StartLocalService.STREAM_NAME));
EventStreamReader<String> reader = streamManager.getClientFactory().createReader(UUID.randomUUID().toString(),
READER_GROUP,
new JavaSerializer<>(),
new ReaderConfig());
for (int i = 0; i < 20; i++) {
String event = reader.readNextEvent(60000).getEvent();
System.err.println("Read event: " + event);
}
reader.close();
System.exit(0);
}
}

0 comments on commit 8ab6861

Please sign in to comment.