activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Mielke <tors...@fusesource.com>
Subject Re: onmessage not picking up messages
Date Mon, 02 Apr 2012 13:32:55 GMT
Its a bit difficult to follow your observations. However forget about the ActiveMQ.Advisory.*
topics, these are just advisory channels (http://activemq.apache.org/advisory-message.html).

Your code snippet below seems to send a message to a queue called MyQueue. If the consumerCount
for that destination is constantly at 0, then there is no consumer connected and hence the
messages will not get dispatched but remain on the queue. 

You will need to look at your consumer side code and try to understand why is it not connecting
to MyQueue? Does it perhaps connect to MyTopic instead? Or to some other destination? Or does
not connect a consumer to the broker at all?


Regards,
Torsten





On Apr 2, 2012, at 2:42 PM, rogerroger wrote:

> Param 'DestinationName' on the message I send(find it in JMX) has
> ActiveMQ.Advisory.TempTopic and TempQueue, not MyQueue.  It is listed under
> Subscription.Non-Durable.Topic...
> 
> 
> I am using this code to produce the message(Can you see why it isn't
> published on MyTopic?):
> 
> 
> String message = "test message";
> Session session = getSession(getQueueConnection());
> TextMessage textMessage = session.createTextMessage();
> textMessage.setText("Sending to queue: "+message);
> getProducer(session, "openejb:Resource/MyQueue").send(textMessage);
> System.out.println("Queue Message w/ id:"+textMessage.getJMSMessageID()+"
> sent");
> 
> 	private Context envContext = null;
> 
> 	private Context getEnvContext() throws NamingException {
> 		if (envContext == null) {
> 			envContext = new InitialContext();
> 			// envContext = (Context) initCtx.lookup("java:comp/env");
> 		}
> 		return envContext;
> 	}
> 
> 	private ConnectionFactory connectionFactory;
> 
> 	private TopicConnection getTopicConnection() throws NamingException,
> 			JMSException {
> 		if (connectionFactory == null) {
> 			connectionFactory = (ConnectionFactory) getEnvContext().lookup(
> 					"openejb:Resource/MyJmsConnectionFactory");
> 		}
> 		return (TopicConnection) connectionFactory.createConnection();
> 
> 	}
> 
> 	private QueueConnection getQueueConnection() throws NamingException,
> 			JMSException {
> 		if (connectionFactory == null) {
> 			connectionFactory = (ConnectionFactory) getEnvContext().lookup(
> 					"openejb:Resource/MyJmsConnectionFactory");
> 		}
> 		return (QueueConnection) connectionFactory.createConnection();
> 
> 	}
> 
> 	private MessageProducer getProducer(Session session, String topicOrQueue)
> 			throws NamingException, JMSException {
> 		MessageProducer producer = session
> 				.createProducer((Destination) getEnvContext().lookup(
> 						topicOrQueue));
> 		return producer;
> 
> 	}
> 
> 	private Session getSession(Connection connection) throws JMSException {
> 		return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> 	}
> 
> 
> and this in openejb.xml:
> 
> 
> 	 <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
>        BrokerXmlConfig =  broker:(tcp://localhost:61616)
>        ServerUrl       =  tcp://localhost:61616
>    </Resource>
> 
>    <Resource id="MyJmsConnectionFactory"
> type="javax.jms.ConnectionFactory">
>        ResourceAdapter = MyJmsResourceAdapter
>    </Resource>
> 
>    <Container id="MyJmsMdbContainer" ctype="MESSAGE">
>        ResourceAdapter = MyJmsResourceAdapter
>    </Container>
> 
>    <Resource id="MyQueue" type="javax.jms.Queue"/>
>    <Resource id="MyTopic" type="javax.jms.Topic"/>
> 
> 
> 
> Torsten Mielke-2 wrote
>> 
>> Hi,
>> 
>> Check using jconsole that a consumer is registered on the destination that
>> you want to consume from. 
>> If its not registered, then there is most likely a problem with your
>> consumer code.
>> 
>> 
>> Hope this serves as a starting point.
>> 
>> 
>> Torsten Mielke
>> torsten@
>> tmielke@
>> 
>> 
>> On Apr 1, 2012, at 11:54 PM, rogerroger wrote:
>> 
>>> Hi
>>> 
>>> I am using tomee plus and it's active mq version.  I have started a
>>> broker,
>>> verified by 'telnet localhost 61616' and added topic and connection
>>> factory
>>> using openejb.xml resource elements.  I am able to send messages to the
>>> broker, verified with the jConsole, but none are consumed.  The same code
>>> worked using tomcat 7.11 and active mc core jar 5.5.1. I am starting up
>>> the
>>> consumers using a servlet listener.  Yes, I have remembered the
>>> connection.start() and there is only one consumer in the code.
>>> 
>>> Help is appreciated.
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>>> http://activemq.2283324.n4.nabble.com/onmessage-not-picking-up-messages-tp4524534p4524534.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>> 
> 
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/onmessage-not-picking-up-messages-tp4524534p4525904.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com




Mime
View raw message