use of org.apache.openejb.resource.activemq.ActiveMQResourceAdapter in project tomee by apache.
the class JmsTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// create a transaction manager
final GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
// create the ActiveMQ resource adapter instance
ra = new ActiveMQResourceAdapter();
// initialize properties
ra.setServerUrl(brokerAddress);
ra.setBrokerXmlConfig(brokerXmlConfig);
ra.setStartupTimeout(new Duration(10, TimeUnit.SECONDS));
// create a thead pool for ActiveMQ
final Executor threadPool = Executors.newFixedThreadPool(30);
// create a work manager which ActiveMQ uses to dispatch message delivery jobs
final TransactionContextHandler txWorkContextHandler = new TransactionContextHandler(transactionManager);
final GeronimoWorkManager workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, Collections.<WorkContextHandler>singletonList(txWorkContextHandler));
// wrap the work mananger and transaction manager in a bootstrap context (connector spec thing)
final BootstrapContext bootstrapContext = new GeronimoBootstrapContext(workManager, transactionManager, transactionManager);
// Create a ConnectionFactory
connectionFactory = new ActiveMQConnectionFactory(brokerAddress);
ra.setConnectionFactory(connectionFactory);
// start the resource adapter
try {
ra.start(bootstrapContext);
} catch (final ResourceAdapterInternalException e) {
throw new OpenEJBException(e);
}
}
Aggregations