unSubscribe to a solcache topic
Currently we use the following code to subscribe to a solcache topic:
cacheSession.sendCacheRequest(Long.valueOf(10011l), "my/topic", true, CacheLiveDataAction.FLOW_THRU, new CacheRequestListener() { @Override public void onException(Long arg0, Topic arg1, JCSMPException arg2) { LOG.error("Consumer Received exception for solace-cache-topic:" + arg2); } @Override public void onComplete(Long arg0, Topic arg1, CacheRequestResult arg2) { String str = String.format("Completed Cache Request for topic: %s with status: %s", arg1.getName(), arg2); } });
Is there any way to unSubscribe to this async request(when needed) so that we dont keep on receiving any new messages being published on this topic?
Many Thanks,
Ali
Best Answer
-
If you do not want to receive any live data at all, just the cache response, you could simply set the 'subscribe' boolean (third argument) to false.
Alternatively you can later unsubscribe using the session that the CacheSession was created on.Session.Unsubscribe("my/topic" , true);
orSession.Unsubscribe("my/topic", false);
as you prefer.Ragnar
6
Answers
-
If you do not want to receive any live data at all, just the cache response, you could simply set the 'subscribe' boolean (third argument) to false.
Alternatively you can later unsubscribe using the session that the CacheSession was created on.Session.Unsubscribe("my/topic" , true);
orSession.Unsubscribe("my/topic", false);
as you prefer.Ragnar
6