You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by klate <Kl...@bank-verlag.de> on 2006/05/19 14:12:05 UTC

Message is read but not removed.

Producer send a message to TestQueue with a non transacted Session

Testing a Consumer with a non transacted Session to receive Messages from
TestQueue
the Message is read but not removed.

Testing a Consumer with a transacted Session and commit 
the Message is read from TestQueue and  removed. 
--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4468266
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by Julian de Anquin <th...@gmail.com>.
I had the same problem, try adding the following code when creating the
connection factory
connectionFactory.setOptimizeAcknowledge(false);
hope it helps, it did with my problmea
cheers
--
View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a4774641
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by klate <Kl...@bank-verlag.de>.
Hi,

The Version I use is:
ActiveMQ Release (08.05.2006)

IBM Blade JS20 AIX 5.3
DB2 DataBase 8.2
Driver 2.5.33

Configuration:

 <broker brokerName="testBrocker" persistent="true" useJmx="false">

<persistenceAdapter>
      
      <jdbcPersistenceAdapter 
class="org.apache.activemq.store.jdbc.adapter.DB2JDBCAdapter" dataSource=
"#db2-ds" >
      </jdbcPersistenceAdapter>

<jdbcPersistenceAdapter
class="org.activemq.store.jdbc.adapter.DefaultJDBCAdapter" dataSource=
"#db2-ds"/>
</persistenceAdapter>

 <transportConnectors>
      	<transportConnector uri="tcp://localhost:61616"/>
    	<transportConnector uri="stomp://localhost:61617"/> 
    </transportConnectors>

    <networkConnectors>
      <!-- by default just auto discover the other brokers -->
        <networkConnector name="default" uri="multicast://default"/> 
    </networkConnectors>
</broker>

<bean id="db2datasource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver"/>
    <property name="url" value="URL"/>
    <property name="username" value="USER"/>
    <property name="password" value="PASS"/>
  </bean>
--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4501413
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by StephenP <st...@putman.org>.
I too have encountered this problem.

It seems to be a bug with the use of javax.jms.Session.AUTO_ACKNOWLEDGE in
ActiveMQ.

When I use  javax.jms.Session.CLIENT_ACKNOWLEDGE (and do
javax.jms.Message.acknowledge()) the message is removed.

Has this bug been logged and reproduced by the dev team?
--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4571887
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by klate <Kl...@bank-verlag.de>.
Hi,

Here a Code Fragment of my Message-Service

Regards 
Klaus Terjung

Producer


public void send() throws NamingException, JMSException {

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        env.put(Context.PROVIDER_URL, "tcp://ws-0148:61616");
        
        InitialContext ctx = new InitialContext(env)

        QueueConnectionFactory  _qconFactory = (QueueConnectionFactory)
ctx.lookup("ConnectionFactory");
        QueueConnection         _qcon        =
_qconFactory.createQueueConnection();
        QueueSession            _qsession    =
_qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        
        
        Queue _queue = (Queue) ctx.lookup(queueName);
        
        QueueSender _qsender = _qsession.createSender(_queue);
        _msg = _qsession.createObjectMessage();
        _msg.setObject(foo);
       
        _qsender.send(_msg);
        _qcon.start();
 }
 
 
 Receiver
 
 
 public void initReceiver() throws NamingException, JMSException {

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        env.put(Context.PROVIDER_URL, "tcp://ws-0148:61616");
        
        InitialContext ctx = new InitialContext(env)

        QueueConnectionFactory  _qconFactory = (QueueConnectionFactory)
ctx.lookup("ConnectionFactory");
        QueueConnection         _qcon        =
_qconFactory.createQueueConnection();
        QueueSession            _qsession    =
_qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        
        
        Queue _queue = (Queue) ctx.lookup(queueName);
        
        QueueSender _qsender = _qsession.createSender(_queue);
        
        _qsession = _qcon.createQueueSession(true,
Session.AUTO_ACKNOWLEDGE);
       
        _queue = (Queue) _ic.lookup(queueName);
      
        QueueReceiver _qreceiver = _qsession.createReceiver(_queue);
        _qreceiver.setMessageListener(listener);
        
        _qcon.start();
 }
 
 
 public void onMessage(Message message) {
        if (message != null) {
            try {
                if (message instanceof ObjectMessage) {
                    
                    Foo foo = (Foo) ((ObjectMessage) message)
                            .getObject();
                            //do something

                    }
                } 
                
                
                if (session().getTransacted()) {
                    session().commit();
                }
                
                

            } catch (JMSException e) {
                throw new FaxServiceException(e);
            }  
  
        
        }
 }
--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4501354
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by klate <Kl...@bank-verlag.de>.
Hello,

If I work with a MessageListener and the onMessage Method
the Messages are not removed from the Queue 

If I work with 
receiver.receiveNoWait();
session.close

the Messages are removed.

Only with session.close the Messages are removed.

Regards
Klaus Terjung

--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4521086
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by James Strachan <ja...@gmail.com>.
Try just using the 4.0.1 distribution which has this option disabled

http://incubator.apache.org/activemq/activemq-401-release.html

On 6/23/06, millea1 <am...@simplestar.com> wrote:
>
> re this line: 'when I set the property via the URL (jms.optimiseAcknowledge)
> I get the IllegalArgumentException: Invalid connect parameters. I had to set
> it programmatically'
>
> We do all settings via xml so it's next to impossible for us to set this
> parm programmatically. Not really that familiar with the software so I'm
> wondering if someone might point me to the optimize code so I can remove it
> here without otherwise breaking things.
>
> Thanks...
> --
> View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a5015901
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Message is read but not removed.

Posted by millea1 <am...@simplestar.com>.
re this line: 'when I set the property via the URL (jms.optimiseAcknowledge)
I get the IllegalArgumentException: Invalid connect parameters. I had to set
it programmatically'

We do all settings via xml so it's next to impossible for us to set this
parm programmatically. Not really that familiar with the software so I'm
wondering if someone might point me to the optimize code so I can remove it
here without otherwise breaking things.

Thanks... 
--
View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a5015901
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by Hugo V <ae...@hotmail.com>.
Also James, 

if you could give us more detail on the 'OptimizedMessageDispatch' property,
it will help us to understand producers behaviours. 

thank you. 
 
--
View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a4774213
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by Hugo V <ae...@hotmail.com>.
Hello,

You are right, when I turn the OptimizeAcknowledge to false, my message gets
remove from the queue. By the way , when I set the property via the URL
(jms.optimiseAcknowledge) I get the IllegalArgumentException: Invalid
connect parameters. I had to set it programmatically. 


Do you have more information or a link on the optimiseAcknowledge property
and what is does exactly. 
There is no information in javadoc. 
It seams like a very important property if it changes the behaviours of the
AUTO_ACKNOWLEDGE in non-transacted mode.


Thank you for your time. 

--
View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a4773353
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by James Strachan <ja...@gmail.com>.
BTW there was an attempt made at optimising acknowledgements which may
have an effect on your issue.

I wonder if disabling the 'optimizeAcknowledge' flag on an
ActiveMQConnection might help fix it?

You can add this to the connection URL like with async send...
http://incubator.apache.org/activemq/async-sends.html

via

tcp://locahost:61616?jms.optimiseAcknowledge=false


On 6/7/06, Hugo V <ae...@hotmail.com> wrote:
>
> Hello again,
>
> We did more testing on this issues. I think the problem is related to the
> pre-fetch parameter. If we force the prefetch to 1 on the connection
> factory, then using a AUTO_ACKNOWLEDGE and non-transacted session is working
> fine (but slow).
>
> If we use the default pre-fetch  (1000) then messages are not all removed
> from the queue.
>
> Thank you
>
> --
> View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a4759864
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Message is read but not removed.

Posted by Hugo V <ae...@hotmail.com>.
Hello again, 

We did more testing on this issues. I think the problem is related to the
pre-fetch parameter. If we force the prefetch to 1 on the connection
factory, then using a AUTO_ACKNOWLEDGE and non-transacted session is working
fine (but slow). 

If we use the default pre-fetch  (1000) then messages are not all removed
from the queue. 

Thank you

--
View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a4759864
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by Hugo V <ae...@hotmail.com>.
Hello,

We are experiencing the same problem here. Messages are delivered but not
removed from the queue in AUTO_ACKNOWLEDGE mode, non-transacted session.

I would like to know if this issue has been addressed ?

--
View this message in context: http://www.nabble.com/Message-is-read-but-not-removed.-t1649736.html#a4758118
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by James Strachan <ja...@gmail.com>.
Any chance you could submt a test case demonstrating your issue along
with giving details of the verison you use?

http://incubator.apache.org/activemq/how-can-i-get-help.html


On 5/22/06, klate <Kl...@bank-verlag.de> wrote:
>
> Hi,
>
> I'am using auto-acknowledge in the non-transacted session.
>
>
>
> Regards
>
> Klaus
>
> --
> View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4500834
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Message is read but not removed.

Posted by klate <Kl...@bank-verlag.de>.
Hi,

I'am using auto-acknowledge in the non-transacted session.



Regards

Klaus

--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4500834
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Message is read but not removed.

Posted by Adrian Co <ac...@exist.com>.
Hi,

In the non-transacted session, are you using auto-acknowledge? It could be
that the client is not acknowledging the receipt of the message. A commit
might send an acknowledge automatically, that is why it is working in the
transacted session.

Regards,
Adrian Co


klate wrote:
> 
> Producer send a message to TestQueue with a non transacted Session
> 
> Testing a Consumer with a non transacted Session to receive Messages from
> TestQueue
> the Message is read but not removed.
> 
> Testing a Consumer with a transacted Session and commit 
> the Message is read from TestQueue and  removed. 
> 
--
View this message in context: http://www.nabble.com/Message+is+read+but+not+removed.-t1649736.html#a4500659
Sent from the ActiveMQ - User forum at Nabble.com.