Skip to content

Run the code

Alexandre D'Erman edited this page Jul 16, 2014 · 12 revisions

Get the code

The easiest way to get the code is to download the last build from the CI ( Then un-tar the archive, you will get a basic file structure as:

  • lib: contains the jar file and their dependency
  • conf: contains the configurations files, especially needed on cluster configuration
  • bin: contains the execution and starting script

if you need to install ZMQ and all its dependencies, we have an installation script validated on Ubuntu, located at the root of the develop branch on github repository: (Thank you Cyrille for the Script!).

Launching RoQ locally

To test the code locally on 1 VM, we have created a simple class the RoQAllLocalLauncher. To start this class just open a terminal, go in the lib directory of the RoQ installation:

java -Djava.library.path=/usr/local/lib -cp roq-simulation-1.0-SNAPSHOT-jar-with-dependencies.jar org.roq.simulation.RoQAllLocalLauncher

This does the following:

  1. create an embedded ZooKeeper server
  2. create a global configuration manager
  3. create a local host configuration manager
  4. add the local host to the global host configuration manager This jar can be found in the target directory of the roq module simulation.

Then we can use the client API to create a queue and creating publishers and subscribers as follows:

 // 1. Create Q
IRoQLogicalQFacrtory factory = new LogicalQFactory(
// 2. Create subscriber
IRoQConnectionFactory connectionFactory = new RoQConnectionFactory(
IRoQSubscriberConnection subscriberConnection = connectionFactory.createRoQSubscriberConnection(
		"queue1", "key");;
subscriberConnection.setMessageSubscriber(new IRoQSubscriber() {
		public void onEvent(byte[] msg) {"On message:" + new String(msg));

// 3. Create publisher
IRoQConnection pubConnection = connectionFactory.createRoQConnection("queue1");;
IRoQPublisher publisher = pubConnection.createPublisher();
publisher.sendMessage("key".getBytes(),"Hello test 1".getBytes());

//4.  Clean all

Launching RoQ on cluster

The easiest way to start RoQ, either in cluster or in standalone machine is to use the starting scripts. There is only two scripts to launch in two terminals and that is all! RoQ is started and you can start writing your client code.

RoQ is launched by two main components:

1. The Global configuration manager (that will start the Management server as well): a starter script can be found in the resources directory of the maven roq-core module. If you get the code from the CI, just go in the bin directory of the RoQ installation.


The Global configuration manager uses a default property file, but you can specify a custom property file as:


2. The Host configuration manager: a starter script can be found in the resources directory of the roq-core module.


The configuration properties for the HCM and the GCM is explained in the page Configuration files.

That's all, RoQ is started if the Global configuration Manager and the Host Configuration manager are started. Note that RoQ needs a running ZooKeeper cluster in order to work.