RE: starting from within a java application
"Tim Anderson" <[email protected]>
| Newsgroups | gmane.comp.java.openjms.user |
|---|---|
| Message-ID | <[email protected]> |
You can start the server via:
Import org.exolab.jms.server.JmsServer;
JmsServer server = new JmsServer("<path to openjms.xml>");
To determine if its running, the easiest approach is simply
try and connect to it:
int retries = 12;
long sleep = 5000;
for (int count = 0; count < retries; ++count) {
try {
InitialContext context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory)
context.lookup("ConnectionFactory");
Connection connection = factory.createConnection();
connection.close();
break;
} catch (Exception exception) {
if (count == retries - 1) {
if (exception instanceof JMSException) {
throw (JMSException) exception;
} else {
JMSException error = new JMSException(
exception.getMessage());
error.setLinkedException(exception);
throw error;
}
}
}
try {
Thread.currentThread().sleep(sleep);
} catch (InterruptedException ignore) {
}
}
To shut down the server:
JmsAdminServerIfc admin = AdminConnectionFactory.create(url);
admin.stopServer();
See also: http://openjms.sourceforge.net/usersguide/admin.html
-Tim
> -----Original Message-----
> From: openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> [mailto:openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf
> Of Leonardo Kenji Shikida
> Sent: Tuesday, 31 January 2006 2:39 AM
> To: [email protected]
> Subject: [openjms-user] starting from within a java application
>
> I would like to code a unit test that starts the openjms
> instance, run tests, clean up, and then closes the openjms
> instance, avoiding explicit System calls.
>
> How could I do that?
>
> best regards
>
> Kenji
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log files for problems? Stop! Download the new AJAX
> search engine that makes searching your log files as easy as
> surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
> _______________________________________________
> openjms-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openjms-user
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642