couchdb changes and vertx

21 views
Skip to first unread message

EclipseTalk

unread,
Aug 12, 2017, 7:24:13 PM8/12/17
to LightCouch
Hello,
I using the change apis to get couchdb document update as follow:


// feed type continuous
changes
= dbClient.changes().includeDocs(true) .since('546').heartBeat(30000).continuousChanges();
 
// live access to continuous feeds
while (changes.hasNext()) {
 
ChangesResult.Row feed = changes.next();
 
 
String docId = feed.getId()
  com
.google.gson.JsonObject doc = feed.getDoc()
 
String seq = feed.getSeq()
 
Gson gson = new Gson()
 
String json = gson.toJson(doc);
 
System.out.println(json);
 
System.out.println("Event docId : " + docId + " - Sequence: " + seq)
 
System.out.println("Event Json doc: " + json)

// Send event to the Vertx event bus....

}


I would like to send an event to the eventbus from the while loop above upon new documents changes and have a consumer verticle handle events from the event bus and respond. 
Where should I create the Vertx instance? Is there any sample code to get me started?
Any help is appreciated.

Thanks

LightCouch

unread,
Aug 14, 2017, 3:37:28 PM8/14/17
to LightCouch
Hi,

You should create the 'Vertx' instance outside the loop, typically it's created once and reused.

Also, you could obtain a 'Gson' instance by 'dbClient.getGson()'.

EclipseTalk

unread,
Aug 16, 2017, 2:56:27 PM8/16/17
to LightCouch, light...@googlegroups.com
Thanks
Reply all
Reply to author
Forward
0 new messages