tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reza Rahman <r...@rahmannet.net>
Subject MDB Listening on external ActiveMQ broker
Date Sun, 10 May 2009 14:21:38 GMT
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


Mime
View raw message