3 Replies Latest reply on Mar 21, 2005 8:45 PM by Adrian Brock

    java.lang.OutOfMemoryError

    li seed Newbie

      In the JBOSS-3.2.4, send data into JBOSSMQ queue.
      When the size of data is over 1M, system send a error message:

      java.lang.OutOfMemoryError
      org.jboss.mq.SpyJMSException: Could not store message: 2 msg=0 hard NOT_STORED PERSISTENT queue=QUEUE.A priority=4 lateClone=false hashCode=23840604; - nested throwable: (java.sql.SQLException: out of memory)


      How to resolve the error?
      Thans.

        • 1. Re: java.lang.OutOfMemoryError
          Adrian Brock Master

          Moderated: Show me some evidence you haven't just posted this error message
          into the forums without first doing some research. Sigh!

          • 2. Re: java.lang.OutOfMemoryError
            li seed Newbie

             

            "adrian@jboss.org" wrote:
            Moderated: Show me some evidence you haven't just posted this error message
            into the forums without first doing some research. Sigh!


            In the JBOSS-3.2.4.
            Use the DefaultDS(hypersonic) to save message.
            If the size of the message(only a message once) is over 1M, JBOSS send a message:
            09:15:45,281 INFO [STDOUT] java.lang.OutOfMemoryError
            09:15:45,406 INFO [STDOUT] **** Reply Message Errororg.jboss.mq.SpyJMSException: Could not store message: 2 msg=0 hard NOT_STORED PERSISTENT queue=QUEUE.A priority=4 lateClone=false hashCode=6951232; - nested throwable: (java.sql.SQLException: out of memory)


            This tiny code snippet
            In the client:
            ////////////////////////////////////////////////////////////////////////////////////
            //getInitialContext: Initialize context by IP.
            InitialContext iniCtx = getInitialContext();
            Object tmp = iniCtx.lookup("ConnectionFactory"); //java:/XAConnectionFactory ConnectionFactory
            QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
            conn = qcf.createQueueConnection();
            queA = (Queue) iniCtx.lookup(strRQueue);
            queB = (Queue) iniCtx.lookup(strLQueue);
            session = conn.createQueueSession(false,
            QueueSession.AUTO_ACKNOWLEDGE);
            conn.start();

            // Set the async listener for queB
            QueueReceiver recv = session.createReceiver(queB);
            recv.setMessageListener(new ExListener());

            // Send a few text msgs to queA
            QueueSender send = session.createSender(queA);
            TextMessage tm = session.createTextMessage(m_strCommand);
            tm.setJMSReplyTo(queB);
            send.send(tm);


            /////////////////////////////////////////////////////////////////////////////////////
            In the server, use MDB:
            //get response message content
            //SessionBean is a session bean
            Inputstream inStream = SessionBean.getMessageContent(....);

            Queue dest = (Queue) message.getJMSReplyTo();
            QueueSender sender = queueSession.createSender(dest);

            BytesMessage tm = queueSession.createBytesMessage();
            tm.setJMSType("BytesMessage");

            if (inStream != null)
            {
            byte[] data = new byte[1024];
            while((count = inStream.read(data, 0, 1024)) != -1){
            tm.writeBytes(data, 0, count);
            }
            inStream.close();
            }

            sender.send(tm);
            // If the size of message reach 1M, error message is sent.
            // If the size of message is less than 1M, this is ok.


            sender.close();

            ///////////////////////////////////////////////////////////////////////////////////

            How to deal with it?
            Thanks.


            • 3. Re: java.lang.OutOfMemoryError
              Adrian Brock Master

              That's what I thought. You didn't even "READ THIS FIRST", let alone use
              search/docs/wiki/faq/etc.