MemcachedClient vs CouchbaseClient


#1

Hi,

Is it possible to set a value via memcached client and retrieve that value via couchbase client?
Im trying to do it but getting error:

Exception in thread "main" com.couchbase.client.java.error.DocumentDoesNotExistException
	at com.couchbase.client.java.CouchbaseAsyncBucket$18.call(CouchbaseAsyncBucket.java:591)
	at com.couchbase.client.java.CouchbaseAsyncBucket$18.call(CouchbaseAsyncBucket.java:578)
	at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
	at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
	at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:101)
	at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:199)
	at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.RemoveResponse.class
	at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:104)
	at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:58)

Thanks for your help.
~Daralis


#2

Which MemcachedClient? Are you referring to spymemcached?

It is possible, yes. The exception you post seems to indicate that the item doesn’t exist in the bucket you’re trying to retrieve things from.

Are you using the same bucket in both cases? If you’re using spymemcached, you’ll need to set up a proxy port to the bucket you want to use. My guess is you may have stored something to one bucket and you’re retrieving from another.


#3

Thanks for your quick response and your help.
1, Yes, spymemcached.
2, Verified, I am on the same bucket.
I did a set via couchbase client and get it from telnet, I got the value from key I just set. Also, I can get the value that set via memcached client using telnet command, but got the exception as below when I tried to get it using couchbase client

Exception in thread “main” com.couchbase.client.java.error.TranscodingException: Flags (0x2) indicate non-JSON document for id DomainBlockingCondition.DomainListHash, could not decode.
at com.couchbase.client.java.transcoder.JsonTranscoder.doDecode(JsonTranscoder.java:60)
at com.couchbase.client.java.transcoder.JsonTranscoder.doDecode(JsonTranscoder.java:40)
at com.couchbase.client.java.transcoder.AbstractTranscoder.decode(AbstractTranscoder.java:42)
at com.couchbase.client.java.CouchbaseAsyncBucket$1.call(CouchbaseAsyncBucket.java:219)
at com.couchbase.client.java.CouchbaseAsyncBucket$1.call(CouchbaseAsyncBucket.java:215)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:101)
at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:199)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


#4

@daralis you are getting closer! This is because spymemcached uses incompatible flags with the SDK 2.x series. So in order to use it, if you are not storing JSON as as string, is to use the LegacyDocument instead of the JsonDocument when fetching it from the Couchbase SDK.


#5

Thanks for your response.
So, We set (via MemcachedClient) the value as a String, how can we retrieve the value via CouchbaseClient? is there anyway to retrieve it without changing the way we set the value via MemcachedClient?

Thanks.
~Daralis.


#6

@daralis: to fetch as a LegacyDocument, as daschl said, you can do the following:

// assuming Bucket bucket
LegacyDocument doc = bucket.get(legacyDocumentId, LegacyDocument.class);
Object content = doc.content(); //this should be the String that you stored using spymemcached

#7

Thanks so so much, Simonbasle and Daschl for all your help.
It works like a charm.
~Daralis