I would like to pick up a specific document from _changes in couchDB.
Here is my query line, where FEED should be "continuous" and HEARTBEAT = "5000"
"?filter=_doc_ids&feed="+FEED+ "&include_docs=true&heartbeat="+HEARTBEAT;
I dont want to request the DB all the time to get the document, but for the DB to push the changes using the above parameters.
This means my c# code needs to keep a connection open for CouchDB to push the changes. This is being executed in its own thread.
I can get data using feed=longpoll, but the c# code just hangs when using continuous.
I'm thinking it has something to do with that im looking at it as an async to produce a .Result, but it should be a stream, so ive tried to do it using streams, but that just turned into a clusterf***. I spent too much time, and could not get it to work. It just stopped executing but not breaking with an exception, so i could not bughunt it.
Therefor i returned to this method, hoping it is possible with a little help :) It works for longpoll, but not for continuous.
internal void Listen (ref JobList jobList)
{
HttpResponseMessage result = null;
try
{
while (true)
{
result = _httpClient.SendAsync(_requestMessage).Result;
var stringResult = result.Content.ReadAsStringAsync();
var resultObject = JsonConvert.DeserializeObject<ImportJobsResponse>(stringResult.Result);
// Transfer the read objects to the jobList
if (null != resultObject)
{
foreach (ImportJob job in resultObject.results[0].doc.ImportJobs)
{
jobList.addJob(job);
}
}
}
} catch (JsonSerializationException jex)
{
// handle error, and write to log.
} catch (Exception ex) // Needs to find out what errors can come here when using httpclient
{
// handle error, and write log.
}
}
Can anybody help :) ty in advance.