Solace Community is getting a facelift!
On March 3rd we will be starting the process of migrating Solace Community to a new platform. As a result, Solace Community will go in to a temporary read-only state. You will still be able to come onto Solace Community and search through posts to find answers, but you won't be able to ask questions, post comments, or react in any way.
We hope to have the migration complete by Wednesday March 5th (or sooner), so please keep an eye out!
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