ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Losing messages when maxdepth hit and transacted=true

Post new topic  Reply to topic
 Losing messages when maxdepth hit and transacted=true « View previous topic :: View next topic » 
Author Message
xmli
PostPosted: Tue Sep 07, 2004 10:13 pm    Post subject: Losing messages when maxdepth hit and transacted=true Reply with quote

Newbie

Joined: 07 Sep 2004
Posts: 3

Hi there. Can anyone help me with my problem?

In my Java project I create an MQQueueSession which is transacted (ie I must commit or rollback manuall). I Write several messages to the queue and then commit them all in one go.

If I set the maxdepth of the target queue to zero then I'll get an MQ exception ... which is great!

But if I set the maxdepth to 1 and send multiple messages then I will not get any exception. The commit will work just fine and the queue will contain the last message sent. All prior messages will have been lost.

Is there a way, either in Java or in the queue setup to ensure that an MQ exception will be thrown when maxdepth is hit, either upon the send or the commit?

Thanks
Jem
_________________
Syntax error detected at or near end of command segment below:-
Back to top
View user's profile Send private message
JLRowe
PostPosted: Wed Sep 08, 2004 12:49 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Are the messages persistent?

If they are, then I would classify this behaviour as a bug.
Back to top
View user's profile Send private message Send e-mail
bower5932
PostPosted: Wed Sep 08, 2004 5:59 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I just tried this with the mqsync.java (straight java not JMS) program from:

http://www.developer.ibm.com/tech/sampmq.html

I set my maxdepth to 1 and attempted to put multiple messages in syncpoint. The first one goes fine (no commit). The second one throws a 2053 (queue full).
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
xmli
PostPosted: Wed Sep 08, 2004 9:20 pm    Post subject: Reply with quote

Newbie

Joined: 07 Sep 2004
Posts: 3

Thanks for the replies.

I tried it from scratch using JMS and it works as intended. The issue lies in our in-house JMS wrapper libraries.

Here's the source that works (as a JUnit test) for any future travellers who are interested:

Code:

import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import junit.framework.TestCase;

import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;

public class zzJemExample extends TestCase
{
    public void testSendTransactedFullQueue() throws Exception
    {
        QueueConnection queueConnection = getQueueConnection();
        queueConnection.start();
        QueueSession queueSession = queueConnection.createQueueSession(true, 0);
        Queue queue = queueSession.createQueue("queue://DGWBNS01/GW_INTSERVER/DEV.MSG.WBC.TEST.ONE_DEPTH?targetClient=1");
        QueueSender sender = queueSession.createSender(queue);

        clearQueue(queueSession, queue);

        sender.send(queueSession.createTextMessage("This is a test - 1"));
        try
        {
            sender.send(queueSession.createTextMessage("This is a test - 2"));
            fail("Expected JMSException");
        }
        catch (JMSException e)
        {
        }
        queueSession.commit();
    }

    private QueueConnection getQueueConnection() throws Exception
    {
        MQQueueConnectionFactory queueConnectionFactory;
        queueConnectionFactory = new MQQueueConnectionFactory();
        queueConnectionFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
        queueConnectionFactory.setHostName("xxxx");
        queueConnectionFactory.setChannel("xxxx");
        queueConnectionFactory.setPort(1415);
        queueConnectionFactory.setQueueManager("xxxx");
        return queueConnectionFactory.createQueueConnection("xxxx", "xxxx");
    }

    private void clearQueue(QueueSession session, Queue queue) throws Exception
    {
        QueueReceiver receiver = session.createReceiver(queue);
        while (receiver.receiveNoWait() != null)
        {
        }
        if (receiver != null)
        {
            receiver.close();
        }
    }
}

_________________
Syntax error detected at or near end of command segment below:-
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Losing messages when maxdepth hit and transacted=true
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.