Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. ConfigFileAuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider('/path/to/.oci/config', 'DEFAULT')
  2. StreamClient client = new StreamClient(provider)
  3. AtomicBoolean closed = new AtomicBoolean(false)
  4.  
  5. CreateGroupCursorDetails cursorDetails = CreateGroupCursorDetails.builder(
  6. .type(CreateGroupCursorDetails.Type.TrimHorizon)
  7. .commitOnGet(true)
  8. .groupName(this.groupName)
  9. .build()
  10. CreateGroupCursorRequest groupCursorRequest = CreateGroupCursorRequest.builder()
  11. .streamId(streamId)
  12. .createGroupCursorDetails(cursorDetails)
  13. .build()
  14.  
  15. CreateGroupCursorResponse cursorResponse = this.client.createGroupCursor(groupCursorRequest)
  16.  
  17. GetMessagesRequest getRequest = GetMessagesRequest.builder()
  18. .cursor(cursorResponse.cursor.value)
  19. .streamId(this.streamId)
  20. .build()
  21.  
  22. while(!closed.get()) {
  23. def getResult = this.client.getMessages(getRequest)
  24. getResult.items.each { Message record ->
  25. def msg = new String(record.value, "UTF-8")
  26. }
  27. getRequest.cursor = getResult.opcNextCursor
  28. sleep(500)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement