7 Replies Latest reply on Aug 18, 2010 10:33 AM by Navin Surtani

    JBoss Cache as a standalone service

    Wasanka Wickramasinghe Newbie

      Hi,

       

      I have a requirement to create and run a jboss cache instance as a standalone application. I have done this by creating a simple class with a main method to create and run the cache. Works fine and I can put/get data.

       

      Now I need to write another java application to put data into this cache by communicating with the first program. These two programs are running in two JVMs.

       

      What are the methods available for me to use? JMX? RMI?

      Could someone please help with an example java code to get an instance of the cache from the first program?

       

      Thanks,

      Udaya

        • 1. Re: JBoss Cache as a standalone service
          Navin Surtani Newbie

          Udaya,

           

          First step - since this seems like a new application that you're writing I'd suggest that you don't use JBoss Cache . JBC hasn't had any development going on it for at least a year or so now. All the new development is on Infinispan now. There is tonnes of documentation out there for you to go and read up on how to write up the application that you require using Infinispan.

           

          Just out of interest, what's the reason that you decided to use JBoss Cache as opposed to Infinispan in the first place? Was it that you just haven't heard of it?

          1 of 1 people found this helpful
          • 2. Re: JBoss Cache as a standalone service
            Wasanka Wickramasinghe Newbie

            Hi Navin,

             

            Thanks for the quick reply and your comments about infinispan.

             

            Yes I have not heard of Infinispan.

             

            I have to use JBoss Cache since the project I'm working started about 2 years back and at that time it was decided to use JBoss Cache. That's the only reason why I need to seek solutions for JBoss Cache. The code that I need to write is an extension to it.

             

            I will definitely read on infinispan :).

            • 3. Re: JBoss Cache as a standalone service
              Navin Surtani Newbie

              How much work has been done on your project that uses JBoss Cache? Naturally people are reluctant to switch over onto a different system because they're lazy - but Infinispan does give you a TreeCache which has more or less the same API as JBC does so you can switch over easier than otherwise.

               

              Just something to suggest to the other guys who work on your project that it's probably a good idea to try and make the switch over to Infinispan because that's where all the cool stuff is happening now.

               

              Also if you don't mind me asking - I'm guessing from your name that you're Sri Lankan. Are you working on a project for a Sri Lankan company? If so, which one are you doing this for?

              • 4. Re: JBoss Cache as a standalone service
                Wasanka Wickramasinghe Newbie

                Hi Navin,

                 

                I'm now reading up on infinispan.

                If you don't mind, could you please give me some examples for getting done what I need. Then I can think of migrating to this with the project approval.

                 

                Sorry, I'm unable to state the company details.

                 

                Thanks again Navin for your replies.

                • 5. Re: JBoss Cache as a standalone service
                  Navin Surtani Newbie

                  Ok, so you have a Cache set-up in a class with a main() method correct? And you have another app running in a different JVM that you need to talk to App 1 with the main method?

                   

                  I'd probably do it as follows, and if any Infinispan guru's see me making a mistake then please point this out.

                   

                  1. Register your cache with a cache manager instance in app1.main()
                  2. In app2 I would create a different cache manager instance and register the *same* cache with app2CacheManager.

                   

                  That should do the trick and allow you to carry out any of the API methods on the cache. However, I think this might negate the need for any main method in app1.

                   

                  Is this helpful?

                  • 6. Re: JBoss Cache as a standalone service
                    Wasanka Wickramasinghe Newbie

                    Hi Navin,

                     

                    But this says that I have two caches which are synchronized. And my second program deal with the cache in hand but since the synchronization happens I will be able to get the required data.

                     

                    Thanks for the answer, but I'm seeking an option of directly communicating with the external cache. Ideal solution is to get an instance of the cache which was started by app1 and then directly performing get/put.

                    • 7. Re: JBoss Cache as a standalone service
                      Navin Surtani Newbie

                      I may not be understanding your problem properly. I am on the #infinispan channel on FreeNode IRC. I have a feeling it would be a lot easier if we just spoke in real time and I can help you out where possible.

                       

                      I think that if you have a CacheManager instance in each app with the same cache name (String) registered to each CM; your caches will be synchronised. This will work as long as long as you use the *same* configuration for each Cache instance.

                       

                      But again, we could be barking up the wrong tree if I don't understand your problem properly. So, if you could find me on IRC would be great. I'm generally online from about 0900GMT up until 1800GMT roughly.