You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by mholodnak <mi...@thermofisher.com> on 2010/09/24 21:53:08 UTC

Newbie confusion regarding JNDI configuration

I explicitly created a Topic named "agility_event_topic_d2" using the default
web admin tool.  My message producer appears to successfully (i.e. without
Exception) post messages to my topic.  However, my consumer never finds any
and the default admin tool indicates that no messages are being sent.

This would indicate that my producer is not actually sending messages to my
topic, likely due to a configuration error.  Here is my producer JNDI
configuration per the JNDI example page:

# JNDI context properties
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://uspgh-agljms-p1.amer.thermo.com:61616?jms.watchTopicAdvisories=false

# JMS resources; I prefer to look these up explicitly instead of using the 
# automated properties
#jms.connection.factory=connectionFactory
#jms.topic=agility_event_topic_d2

# use the following property to specify the JNDI name the connection factory
# should appear as. 
connectionFactoryNames=connectionFactory, queueConnectionFactory,
topicConnectionFactory

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
#queue.MyQueue = example.MyQueue


# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.ForwardTopic=agility_event_topic_d2

Here is the chunk of code that produces the message (its in an MDB deployed
in WebLogic that listens to a queue then forwards messages from that
WebLogic Queue to the ActiveMQ Topic):

	public void onMessage(Message message)
	{
		logger.info("Starting 'onMessage("+message.getClass().getName()+")'");
		try
		{
			this.connection.start();
			this.session = this.connection.createTopicSession(true,
TopicSession.AUTO_ACKNOWLEDGE);
			try
			{
				TopicPublisher publisher = this.session.createPublisher(topic);
				//publisher.send(message);
				publisher.publish(message);
				
				this.session.commit();
				this.session.close();
				this.connection.stop();
				this.connection.close();
				
				logger.info("Successfully posted message of type
"+message.getClass().getName());
			}
			catch (Exception ex)
			{
				logger.warn("Error forwarding message.", ex);
				this.session.rollback();
			}
		}
		catch (Exception ex)
		{
			String messageStr = "A fatal JMS exception has occured while trying to
access JMS objects";
			logger.error(messageStr, ex);
			throw new RuntimeException(messageStr, ex);
		}
		
		logger.info("Completed 'onMessage("+message.getClass().getName()+")'");
	}


-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Newbie-confusion-regarding-JNDI-configuration-tp2582968p2582968.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Newbie confusion regarding JNDI configuration

Posted by mholodnak <mi...@thermofisher.com>.
Nevermind, the configuration was not the issue.  My problem was related to my
producer being in WebLogic. It is an MDB listening to a Queue in WebLogic
meant to forward the message to another server running ActiveMQ.  ActiveMQ
would obviously not have the WebLogic JMS implementation classes available,
and thus could not process the message, though why it did not throw an
Exception or otherwise indicate a problem caused me to waste a couple of
days trying to figure why my messages were not getting through.  My solution
was to "rebuild" the message (I use a bunch of JMS properties in addition to
using an object body) using the target ActiveMQ objects which was kind of
painful but it works.

It would be nice if there were a "copy" or "duplicate" facility that worked
at the JMS API level instead of the implementation level (there is an
ActiveMQ implementation-side copy, but that won't work with a WebLogic
message implementation).

-Mike
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Newbie-confusion-regarding-JNDI-configuration-tp2582968p2716011.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.