Created
March 14, 2019 15:45
-
-
Save recursivecodes/deb2078f2215614d4e9b14eb8d67d86b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ConfigFileAuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider('/path/to/.oci/config', 'DEFAULT') | |
| StreamClient client = new StreamClient(provider) | |
| AtomicBoolean closed = new AtomicBoolean(false) | |
| CreateGroupCursorDetails cursorDetails = CreateGroupCursorDetails.builder( | |
| .type(CreateGroupCursorDetails.Type.TrimHorizon) | |
| .commitOnGet(true) | |
| .groupName(this.groupName) | |
| .build() | |
| CreateGroupCursorRequest groupCursorRequest = CreateGroupCursorRequest.builder() | |
| .streamId(streamId) | |
| .createGroupCursorDetails(cursorDetails) | |
| .build() | |
| CreateGroupCursorResponse cursorResponse = this.client.createGroupCursor(groupCursorRequest) | |
| GetMessagesRequest getRequest = GetMessagesRequest.builder() | |
| .cursor(cursorResponse.cursor.value) | |
| .streamId(this.streamId) | |
| .build() | |
| while(!closed.get()) { | |
| def getResult = this.client.getMessages(getRequest) | |
| getResult.items.each { Message record -> | |
| def msg = new String(record.value, "UTF-8") | |
| } | |
| getRequest.cursor = getResult.opcNextCursor | |
| sleep(500) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment