🎄 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.

SolCache

amishra
amishra Member Posts: 10

I am Trying to Lookup a distributed cache on my VPN using below snippet . I am not able to connect distributed Cache configured .Can someone provide me details to read Cached information from configured distributed Cache using Java API.

        // Connect, create a producer and a consumer, and start the consumer.
        session.connect();
        prod = session.getMessageProducer(new PubCallback());
        cons = session.getMessageConsumer(new PrintingMessageHandler());
        printRouterInfo();
        cons.start();
        Topic topic = JCSMPFactory.onlyInstance().createTopic(SampleUtils.SAMPLE_TOPICENDPOINT);

        // Publish a single message to make sure there is something cached.
        BytesXMLMessage msg = JCSMPFactory.onlyInstance().createMessage(BytesXMLMessage.class);
        msg.writeAttachment("published message".getBytes());
        prod.send(msg, topic);

        // Create the cache session based on parameters on the command line.
        cacheSession = SampleUtils.newCacheSession(session, conf);

        // Perform the cache request.
     **   CacheRequestResult result = cacheSession.sendCacheRequest(1L, topic, 
                conf.getSubscribe(), conf.getAction());**
        System.out.println("Cache Request=" + result + ", Cached Messages Received=" + 
                session.getSessionStats().getStat(StatType.CACHED_MSGS_RECVED));

I am getting Timed out Exception while reading from cache .

Best Answer

Answers

  • amishra
    amishra Member Posts: 10

    Thanks !! It works solCache instance needs to be operational !!

  • Glad to hear it's working. If it helps, what you setup on the Event Brokers around SolCache is just configuration for how you want the actual SolCache instances to behave, it doesn't actually run the Caches itself. This allows you to centrally manage configuration which greatly simplifies your Cache instances. All you configure in the instances is where and how they login to Solace to grab their configuration and start caching messages.