简体   繁体   中英

Standalone ActiveMQ client on GlassFish

Hello guys i have such issue i make all thing like tutorial says. So now i want to lookup my Topics and connection factories that i configured but it do not see them. i make something like :

  try { Properties propertiesAMQ = new Properties(); propertiesAMQ.load(new FileInputStream("AMQ.properties")); logger.info("Property file loaded succesfully..."); propertiesAMQ.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); propertiesAMQ.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616"); Context ctx = new InitialContext(propertiesAMQ); javax.jms.TopicConnectionFactory factory = (javax.jms.TopicConnectionFactory) ctx .lookup("amqpool"); javax.jms.Topic mytopic = (javax.jms.Topic) ctx.lookup("amqmsg") 

}

And recieve NameNotFoundException. If i use name of connection factory such as "ConnectionFactory" it will be ok but then it will not see my Topic What i did wrong? Have u other examples of this subject? I'm using glassfish 3.0.1 and AMQ 5.5.0

可能您缺少名称空间,可以在glassfish控制台中查找确切的名称,但是很可能应该是这样;

javax.jms.Topic mytopic = (javax.jms.Topic) ctx.lookup("java:amqmsg")

How do you create your Topic resource? I had a similar problem and the solution was to create the Admin Resource Object using Glassfish command-line tool 'asadmin'. Creating it using the Glassfish admin console did not work (causing NameNotFoundException).

I ended up creating my Queu resource with the following command: 'create-admin-object –restype javax.jms.Queue –raname activemq-rar-5.7.0 –property PhysicalName=queueName queueName'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM