-
Feature Request
-
Resolution: Unresolved
-
Major
-
None
-
None
Here's a typical usage of the MSC async start/stop API, here with a StartContext:
final Runnable task = new Runnable() { @Override public void run() { try { jmsManager.createQueue(false, queueName, selectorString, durable, jndi); queue = new HornetQQueue(queueName); context.complete(); } catch (Throwable e) { context.failed(MESSAGES.failedToCreate(e, "queue")); } } }; try { executorInjector.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); }
A bit nicer would be:
final Callable<Void> task = new Callable<Void>() { @Override public Void call() { try { jmsManager.createQueue(false, queueName, selectorString, durable, jndi); queue = new HornetQQueue(queueName); return null; } catch (Throwable e) { throw MESSAGES.failedToCreate(e, "queue"); } } }; context.asynchronous(executorInjector.getValue(), task);
A similar thing for StopContext would be cleaner since a Runnable could be used for 'task', as there is no need for the task to be able to throw StartException for the failure case.