Topics working, queues aren't

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Topics working, queues aren't

fhenskens
Hi,

I'm using ActiveMQ 5.14.3 in TomEE 7.0.3

I've migrated an old EE app from weblogic to TomEE.

The Topic setup is working perfectly, including message selectors and
forwarding between topics.

Debugging, the queue isn't exceptioning out when sending messages, however
the consumer isn't actually consuming anything.

Here are some appropriate code sections:

From Command.java (implements serializable)

    public synchronized void queue( final InitialContext context, final
boolean postpone ) throws JMSException,
                                                                               
NamingException
    {
        final ConnectionFactory connectionFactory =
            (ConnectionFactory)Application.getInitialContext().lookup(
                "openejb:Resource/JmsConnectionFactory" );
        final Connection connection = connectionFactory.createConnection();
        connection.start();
        final Session session =
            connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        final Queue commandQueue =
            (Queue)Application.getInitialContext().lookup(
                "openejb:Resource/CommandQueue" );
        final MessageProducer sender = session.createProducer(commandQueue);
        final ObjectMessage message = session.createObjectMessage(this);
        if ( postpone )
        {
            message.setLongProperty(
                ScheduledMessage.AMQ_SCHEDULED_DELAY,
                getRetryIntervalMinutes() * 60000 );
        }
        sender.send( message );
        try { sender.close(); } catch ( final Exception e ) {}
        try { session.close(); } catch ( final Exception e ) {}
        try { connection.close(); } catch ( final Exception e ) {}
    }

From CommandExecutorMDB:

@MessageDriven(name = "CommandExecutorMDB", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination",
propertyValue = "CommandQueue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge") })
@LocalClient
public class CommandExecutorMDB implements MessageListener
{
    @Resource
    private ConnectionFactory myConnectionFactory;

    @Resource( name="CommandQueue" )
    private Queue myCommandQueue;

    /* (non-Javadoc)
     * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
     */
    @Override
    public void onMessage( final Message msg )
    {
        try
        {
            Command command = null;

            // We got a message, try to read it
            try
            {
                command = Command.read( msg );
                if ( command == null )
                {
                    throw new Exception(
                        "Null message received on command queue" );
                }
            }
            catch ( final Exception e )
            {
                DefaultLog.getDefaultLog().logError( "Error reading message
from JMS queue. Committing the transaction and trying again.", e );
            }

            // attempt the command.
            command.attempt( Application.getInitialContext() );
        }
        catch ( final Exception e )
        {
            DefaultLog.getDefaultLog().logError( "Internal error while
attempting Command. ", e );
        }
    }
}

Debugging shows a successful step-through of Command, sending without
exception. CommandExecutorMDB's onMessage method is never entered.

Any ideas how I stuffed it up?



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Topics working, queues aren't

fhenskens
Monitoring in JMX, EnqueueCounter is 0, DequeueCounter is 0, ConsumedCount is
0. I can set a breakpoint and watch producers. Debugging, I can see my
producer appear, say it's sent one message, and disappear.

The consumer never consumes anything - never says it has anything waiting to
be processed. I'm so stumped.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Topics working, queues aren't

fhenskens
Looking at ActiveMQ.Advisory.Producer.Queue.CommandQueue, EnqueueCount is 4,
DispatchCount is 0, DequeueCount is 0. EnqueueCount increments as more
messages are sent.

Looking at ActiveMQ.Advisory.Consumer.Queue.CommandQueue, EnqueueCount is 1,
DispatchCount is 0, DequeueCount is 0. These values never change.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html