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/31 13:27:36 UTC

Bug in createQueueSession ?

Hi,

Is it a bug with  javax.jms.Session.AUTO_ACKNOWLEDGE in ActiveMQ ?

When I use createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE)
the Messages are not removed from the Queue.


When I use createQueueSession(true, javax.jms.Session.AUTO_ACKNOWLEDGE) and
call getSession().commit() in the onMessage Method

the Messages are  removed from the Queue.

I work with ActiveMQ Release (30.05.2006).

Best Regards

Klaus Terjung
--
View this message in context: http://www.nabble.com/Bug+in+createQueueSession+--t1710085.html#a4642714
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Bug in createQueueSession ?

Posted by sL07 <lu...@asteriski.com>.
hi guys,

what is the state of this issue.?

I am seeing the same behaviour.

Is there a work around besides calling session.commit() as my
MessageCOnsumer does not have access to the session.

many thanks


--
View this message in context: http://www.nabble.com/Bug-in-createQueueSession---t1710085.html#a4674311
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Bug in createQueueSession ?

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);

        _qcon.start();
       
        _msg = _qsession.createObjectMessage();
        _msg.setObject(foo);
       
        _qsender.send(_msg);
       
 }
 
 
 Receiver/Consumer
  
 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);
       
         _qcon.start();

        _qsession = _qcon.createQueueSession(true,
Session.AUTO_ACKNOWLEDGE);
       
        _queue = (Queue) _ic.lookup(queueName);
     
        QueueReceiver _qreceiver = _qsession.createReceiver(_queue);
        _qreceiver.setMessageListener(listener);
       
       
 }
 
 
 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/Bug+in+createQueueSession+--t1710085.html#a4643025
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Bug in createQueueSession ?

Posted by James Strachan <ja...@gmail.com>.
On 5/31/06, klate <Kl...@bank-verlag.de> wrote:
>
> Hi,
>
> Is it a bug with  javax.jms.Session.AUTO_ACKNOWLEDGE in ActiveMQ ?
>
> When I use createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE)
> the Messages are not removed from the Queue.

How are you consuming the messages?

Could you show us the Java code you are using?

James

> When I use createQueueSession(true, javax.jms.Session.AUTO_ACKNOWLEDGE) and
> call getSession().commit() in the onMessage Method
>
> the Messages are  removed from the Queue.
>
> I work with ActiveMQ Release (30.05.2006).
>
> Best Regards
>
> Klaus Terjung
> --
> View this message in context: http://www.nabble.com/Bug+in+createQueueSession+--t1710085.html#a4642714
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

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