🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
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