You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by hretter <hr...@conciselogic.com> on 2009/01/29 15:48:13 UTC

JMS Topic and ActiveMQ

Using tomcat/openejb, I'm trying to create a JMS Topic for use by a web
application and remote clients.  So far, I have the following code that
returns a valid TopicConnectionFactory.

      Properties properties = new Properties();
   		properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
			properties.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");

			InitialContext context = new InitialContext(properties);
			TopicConnectionFactory conFactory = (TopicConnectionFactory)
context.lookup("TopicConnectionFactory");

      // this code lifted from openejb examples JNDIServlet 
			Map<String, Object> bindings = new TreeMap<String,
Object>(String.CASE_INSENSITIVE_ORDER);
			addBindings("", bindings, context);
      printBindings(bindings);

printBindings outputs this:

      JNDI Context:
       
ConnectionFactory=org.apache.activemq.ActiveMQConnectionFactory@1d686c1
        dynamicQueues=
        dynamicTopics=
       
QueueConnectionFactory=org.apache.activemq.ActiveMQConnectionFactory@128edf2
       
TopicConnectionFactory=org.apache.activemq.ActiveMQConnectionFactory@1dddba

What do I have to add to openejb.xml to define my topic "jms/SmsTopic"?
I have tried putting this in openejb.xml:

<Resource id="jms/SmsTopic" type="javax.jms.Topic">
  destination smsTopic
</Resource>


Thanks.

-- 
View this message in context: http://www.nabble.com/JMS-Topic-and-ActiveMQ-tp21728285p21728285.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: JMS Topic and ActiveMQ

Posted by hretter <hr...@conciselogic.com>.
Well, if I use ActiveMQ's "dynamicTopics/xxx" naming scheme at both ends (pub
and sub connect to "dynamicTopic/SmsTopic") it works.  

I would like to use JMS for portability, though.


 



hretter wrote:
> 
> Using tomcat/openejb, I'm trying to create a JMS Topic for use by a web
> application and remote clients.  So far, I have the following code that
> returns a valid TopicConnectionFactory.
> 
>       Properties properties = new Properties();
>    		properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> 			properties.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");
> 
> 			InitialContext context = new InitialContext(properties);
> 			TopicConnectionFactory conFactory = (TopicConnectionFactory)
> context.lookup("TopicConnectionFactory");
> 
>       // this code lifted from openejb examples JNDIServlet 
> 			Map<String, Object> bindings = new TreeMap<String,
> Object>(String.CASE_INSENSITIVE_ORDER);
> 			addBindings("", bindings, context);
>       printBindings(bindings);
> 
> printBindings outputs this:
> 
>       JNDI Context:
>        
> ConnectionFactory=org.apache.activemq.ActiveMQConnectionFactory@1d686c1
>         dynamicQueues=
>         dynamicTopics=
>        
> QueueConnectionFactory=org.apache.activemq.ActiveMQConnectionFactory@128edf2
>        
> TopicConnectionFactory=org.apache.activemq.ActiveMQConnectionFactory@1dddba
> 
> What do I have to add to openejb.xml to define my topic "jms/SmsTopic"?
> I have tried putting this in openejb.xml:
> 
> <Resource id="jms/SmsTopic" type="javax.jms.Topic">
>   destination smsTopic
> </Resource>
> 
> 
> Thanks.
> 
> 

-- 
View this message in context: http://www.nabble.com/JMS-Topic-and-ActiveMQ-tp21728285p21732376.html
Sent from the OpenEJB User mailing list archive at Nabble.com.