Skip to content

Instantly share code, notes, and snippets.

@recursivecodes
Created March 14, 2019 15:45
Show Gist options
  • Select an option

  • Save recursivecodes/deb2078f2215614d4e9b14eb8d67d86b to your computer and use it in GitHub Desktop.

Select an option

Save recursivecodes/deb2078f2215614d4e9b14eb8d67d86b to your computer and use it in GitHub Desktop.
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