Skip to main content

Embedding Q2

· One min read
Alejandro Revilla

People sometimes use jPOS as a library and do the wiring using Java code, something that Q2 already does in a clean and easy to maintain way. In r2735 we've introduced a couple of changes to Q2 in order to simplify the way you can embed it in your application in order to get the best of both worlds. You basically need to instantiate a Q2 object and call its start() method. That's it. At shutdown time, you call stop() on that instance. There's no reason not to use Q2 now, you just need to:

import org.jpos.q2.Q2;
...
...
Q2 q2 = new Q2("path/to/your/deploy/directory");
q2.start();
...
...

At stop time, you simply call:

  q2.stop();