Search This Blog

Thursday, 30 September 2010

Running Coherence Query/Command line clients in JDeveloper 11g

Always wanted to run the command line client and query client from JDeveloper but because JDeveloper does not allow you to specify a runnable class which belongs in a JAR file this is not possible. However thanks to the help of an internal employee I found you can do it as follows

The two clients are these two scripts below which use a class in coherence.jar as follows

coherence.cmd - com.tangosol.net.CacheFactory
query.cmd (New In Coherence 3.6) - com.tangosol.coherence.dslquery.QueryPlus

1. Create a new empty project in JDeveloper
2. Add 2 classes as follows for each client.

coherence.cmd - com.tangosol.net.CacheFactory
package pas.au.coherence.utils;

import com.tangosol.net.CacheFactory;

public class JdevCoherenceClient extends CacheFactory
{
  public JdevCoherenceClient()
  {
  }
}

query.cmd (New In Coherence 3.6) - com.tangosol.coherence.dslquery.QueryPlus
package pas.au.coherence.utils;

import com.tangosol.coherence.dslquery.QueryPlus;

public class JdevCoherenceQueryClient extends QueryPlus
{
  public JdevCoherenceQueryClient()
  {
  }
}

3.At a minimum if we use the default cache config file in coherence.jar we simply need to create a run/debug/profile for each client as follows. This is the example for the QueryPlus client where the config is called "CoherenceQueryClient"


Notice how I have set the JVM propery -Dtangosol.coherence.ttl=0 to avoid joining any clusters outside my own machine. Basically this will ensure no packets are sent from my machine. You would specify any other properties here for coherence such as -Dtangosol.coherence.cacheconfig if you have your own config file. Also the "Default Run target" is set to the class we created above which will then use the class we extended.

4. In that dialog select "Tool Settings" and ensure "Allow program Input" is checked as we need to type at the command prompt.

5. Now run your config select the Run icon in the toolbar and then selecting one of the 2 config you created.

Output in the log window would be as follows

No comments: