Title: JMS Resources and MDB Container
# External ActiveMQ Broker
# Do not start the embedded ActiveMQ broker
BrokerXmlConfig
ServerUrl tcp://someHostName:61616
ResourceAdapter MyJmsResourceAdapter
ResourceAdapter MyJmsResourceAdapter
The {{ServerUrl}} would be changed to point to the host and port of the
ActiveMQ process. The various URL formats that ActiveMQ supports also
work, such as 'failover:'.
The same can be done via properties in an embedded configuration, via the
{{conf/system.properties}} file or on the command line via {{-D}} flags.
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
p.put("MyJmsResourceAdapter", "new://Resource?type=ActiveMQResourceAdapter");
p.put("MyJmsResourceAdapter.ServerUrl", "tcp://someHostName:61616");
// Do not start the ActiveMQ broker
p.put("MyJmsResourceAdapter.BrokerXmlConfig", "");
p.put("MyJmsConnectionFactory", "new://Resource?type=javax.jms.ConnectionFactory");
p.put("MyJmsConnectionFactory.ResourceAdapter", "MyJmsResourceAdapter");
p.put("MyJmsMdbContainer", "new://Container?type=MESSAGE");
p.put("MyJmsMdbContainer.ResourceAdapter", "MyJmsResourceAdapter");
p.put("FooQueue", "new://Resource?type=javax.jms.Queue");
p.put("BarTopic", "new://Resource?type=javax.jms.Topic");
InitialContext context = new InitialContext(p);
From anywhere in the same VM as the EJB Container you could lookup the
above resources like so:
javax.jms.ConnectionFactory cf = (ConnectionFactory)
context.lookup("openejb:Resource/MyJmsConnectionFactory");
javax.jms.Queue queue = (Queue) context.lookup("openejb:Resource/FooQueue");
javax.jms.Topic topic = (Topic) context.lookup("openejb:Resource/BarTopic");
# Internal ActiveMQ Broker
_TODO_