Try PubSub+

SolCache

amishraamishra 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

  • amishraamishra Member Posts: 10

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

  • kovkov Member, Employee Posts: 16 Solace Employee

    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.

Sign In or Register to comment.