SHARE
TWEET

Untitled

a guest Mar 19th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top