Hi

I have a JMS queue and two consumers.

One is an MDB

@MessageDriven(activationConfig = {
                @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
                @ActivationConfigProperty(propertyName = "destination",
propertyValue = "FooQueue"),
                @ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge") })

Another is a class that creates a consumer to "delete" specific
messages by ID, let's call it class C

        public void remove(String jmsMessageID) throws JMSException{
                
                Connection connection = null;
                Session session = null;
                try {
                        ConnectionFactory connectionFactory =
this.baseService.getConnectionFactory();
                        connection = connectionFactory.createConnection();
                        connection.start();

                        // Create a Session
                        session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
                        Queue queue = this.baseService.getQueue();
                        MessageConsumer consumer =
session.createConsumer(queue,"JMSMessageID='"+jmsMessageID+"'");
                        Message message = consumer.receive(3000);
                        while(message != null){                 
                                System.out.println("Consumed > "+message);
                                message = consumer.receive(1);
                        }
                        
                } finally {
                        if (session != null)
                                session.close();
                        if (connection != null)
                                connection.close();
                }
        }

When I comment the MDB class, the C.remove() works

When I let the MDB consume from the same queue, C.remove does not work
anymore because the message is always null (even if the message to be
consumed is not being consumed at the moment)

Is that related somehow to activeMQ "prefetch" mechanism? I mean, does
it "lock" some messages to be consumed? If so, is that the right way
to disable the prefetching?

        <Resource id="Default JMS Resource Adapter" 
type="ActiveMQResourceAdapter">
                BrokerXmlConfig = broker:(tcp://localhost:61616)?persistent=true
                ServerUrl = tcp://localhost:61616?jms.prefetchPolicy.all=0
                DataSource = MyJmsDataSource
                maximumRedeliveries = -1
        </Resource>

Or am I missing something here?

My JMS messages are persistent.

TIA

Leo

Reply via email to