Hi,
I was able to get the MDB listening on the remote topic. There were two
issues. The first was that I had the same MDB in the classpath for the
Tomcat web app. The second is that ActiveMQ did not recognize async=true
for remote servers. Here is the fix:
properties.put("Default JMS Resource Adapter.ServerUrl",
"tcp://localhost:61616");
I still would like to have an answer to the JUnit support question.
Also, I would like to not create an embedded broker on the command-line
client at all. I tried keeping the BrokerXmlConfig null or empty. null
tried to create a remoted broker and empty resulted in an error message.
Many thanks in advance,
Reza
------------------------------------------------
Expert Group Member, EJB 3.1 and Java EE 6
Author, EJB 3 in Action
Independent Consultant
Reza Rahman wrote:
Hi,
I am trying to connect an OpenEJB MDB embedded in a Java SE command-line
application to a JMS topic inside an ActiveMQ embedded broker running
inside Tomcat/OpenEJB. The MDB works fine when it is inside Tomcat, but
that's not that useful in this scenario since I want to perform remote
notification to the Java SE program running outside Tomcat. Here is my
SE bootstrap code:
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
properties.put("Default JMS Resource Adapter",
"new://Resource?type=ActiveMQResourceAdapter");
properties.put("Default JMS Resource Adapter.BrokerXmlConfig",
"broker:vm://localhost"); // Ideally, I don't want an embedded broker
here at all.
properties.put("Default JMS Resource Adapter.ServerUrl",
"tcp://localhost:61616?async=true"); // Trying to connect to the Tomcat
broker.
new InitialContext(properties);
Here is the MDB container configuration on the Tomcat/OpenEJB side:
<Resource id="My JMS Resource Adapter" type="ActiveMQResourceAdapter">
# Broker configuration URI as defined by ActiveMQ
# see http://activemq.apache.org/broker-configuration-uri.html
BrokerXmlConfig broker:(tcp://localhost:61616)?useJmx=false // Should
be listening to remote clients
# Broker address
ServerUrl vm://localhost?async=true // Should start an embedded broker.
# DataSource for persistence messages
DataSource My Unmanaged DataSource
</Resource>
Here is my MDB configuration:
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination",
propertyValue = "alertTopic") }) // Can I connect directly to the remote
topic instead?
Can anyone help?
Many thanks in advance,
Reza
------------------------------------------------
Expert Group Member, EJB 3.1 and Java EE 6
Author, EJB 3 in Action
Independent Consultant