Getting IllegalAgrEception while Sending BlobMessage

View: New views
3 Messages — Rating Filter:   Alert me  

Getting IllegalAgrEception while Sending BlobMessage

by susuguna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi ,


I am trying a simple producer consumer application for BlobMessage it works  fine for files of size 8 kb if I send file of size more than 8 MB it throws an exception in the activemq console

ERROR log                            - EXCEPTION
java.lang.IllegalArgumentException
        at java.nio.Buffer.position(Buffer.java:218)
        at org.mortbay.io.nio.NIOBuffer.poke(NIOBuffer.java:142)
        at org.mortbay.io.AbstractBuffer.put(AbstractBuffer.java:391)
        at org.mortbay.jetty.HttpParser.reset(HttpParser.java:844)
        at org.mortbay.jetty.HttpConnection.destroy(HttpConnection.java:131)
        at org.mortbay.jetty.AbstractConnector.connectionClosed(AbstractConnector.java:785)
        at org.mortbay.jetty.nio.SelectChannelConnector.access$100(SelectChannelConnector.java:64)
        at org.mortbay.jetty.nio.SelectChannelConnector$1.endPointClosed(SelectChannelConnector.java:92)
        at org.mortbay.io.nio.SelectChannelEndPoint.doUpdateKey(SelectChannelEndPoint.java:382)
        at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:337)
        at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:166)
        at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)
        at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:537)



what could be the problem?


RE: Getting IllegalAgrEception while Sending BlobMessage

by Angers, Sebastien :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Suresh,

Could you give more details?

Using the following very simple code, it is working for files of 8 kb and also for files of 14 MB.

Regards,

Sébastien

----------------------

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.BlobMessage;

import org.apache.activemq.command.ActiveMQQueue;

public class ActiveMQBlobExperiment {
       
        /**
         * This method will produce a file on the queue and will save it under the $brokerLocation$/webapps/fileserver/.
         *
         * @param file
         */
        public static void produce(File file){
               
                ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:8161/fileserver/");
                               
                try {
                        ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
                        ActiveMQSession session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                        Destination destination = new ActiveMQQueue("BlobQueue");
                        MessageProducer producer = session.createProducer(destination);
                       
                        connection.setCopyMessageOnSend(false);

                        BlobMessage message = session.createBlobMessage(file);

                        producer.send(message);
                       
                        // Clean up
                        producer.close();
                        session.close();
                        connection.close();
                       
                } catch (Exception e) {
                        e.printStackTrace();
                        System.exit(-1);
                }
        }
       
        public static void consume(){
                try {
                       
                        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:8161/fileserver/");

                        ActiveMQConnection conn = (ActiveMQConnection) connectionFactory.createConnection();
                        conn.start();

                        ActiveMQSession session = (ActiveMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
                               
                        Destination destination = new ActiveMQQueue("BlobQueue");

                        MessageConsumer consumer = session.createConsumer(destination);

                        // Wait for a message
                        Message message = consumer.receive(1000);

                        if (message instanceof BlobMessage) {
                                BlobMessage blobMessage = (BlobMessage) message;

                                InputStream in = blobMessage.getInputStream();
                               
                                StringBuffer out = new StringBuffer();
                                byte[] b = new byte[4096];
                                for (int n; (n = in.read(b)) != -1;) {
                                        out.append(new String(b, 0, n));
                                }

                                System.out.println("Text Blob Content: " + out.toString());

                        } else {
                                System.out.println("Received: " + message);
                        }

                        // Clean up
                        consumer.close();
                        session.close();
                        conn.close();
                       
                } catch (Exception e) {
                        e.printStackTrace();
                        System.exit(-1);
                }
        }
               
        public static void main(String[] args) throws IOException {
                File smallFile = new File("SmallFile.dat"); // <---- set the path to the small file here!!
                File bigFile = new File("BigFile.dat"); // <---- set the path to the big file here!!
               
                produce(smallFile);
                consume();
                produce(bigFile);
                consume();
        }

       
}


Le contenu de ce courriel s'adresse au destinataire seulement. Il contient de l'information pouvant être confidentielle. Vous ne devez ni le copier ni l'utiliser ni le divulguer à qui que ce soit à moins que vous soyez le destinataire ou une personne désignée autorisée. Si vous le receviez par erreur, veuillez nous aviser immédiatement et le détruire.
 

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

 

From: susuguna [mailto:suresh.sugunan@...]
Sent: Monday, June 09, 2008 8:17 AM
To: users@...
Subject: Getting IllegalAgrEception while Sending BlobMessage


Hi ,


I am trying a simple producer consumer application for BlobMessage it works
fine for files of size 8 kb if I send file of size more than 8 MB it throws
an exception in the activemq console

ERROR log                            - EXCEPTION
java.lang.IllegalArgumentException
        at java.nio.Buffer.position(Buffer.java:218)
        at org.mortbay.io.nio.NIOBuffer.poke(NIOBuffer.java:142)
        at org.mortbay.io.AbstractBuffer.put(AbstractBuffer.java:391)
        at org.mortbay.jetty.HttpParser.reset(HttpParser.java:844)
        at org.mortbay.jetty.HttpConnection.destroy(HttpConnection.java:131)
        at
org.mortbay.jetty.AbstractConnector.connectionClosed(AbstractConnector.java:785)
        at
org.mortbay.jetty.nio.SelectChannelConnector.access$100(SelectChannelConnector.java:64)
        at
org.mortbay.jetty.nio.SelectChannelConnector$1.endPointClosed(SelectChannelConnector.java:92)
        at
org.mortbay.io.nio.SelectChannelEndPoint.doUpdateKey(SelectChannelEndPoint.java:382)
        at
org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:337)
        at
org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:166)
        at
org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)
        at
org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:537)



what could be the problem?


--
View this message in context: http://www.nabble.com/Getting-IllegalAgrEception-while-Sending-BlobMessage-tp17731668p17731668.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Getting IllegalAgrEception while Sending BlobMessage

by Bala M :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am also getting the same errror! Has this issue been solved?

Please let me know the reason for the error?

Thanks,
Bala
susuguna wrote:
Hi ,


I am trying a simple producer consumer application for BlobMessage it works  fine for files of size 8 kb if I send file of size more than 8 MB it throws an exception in the activemq console

ERROR log                            - EXCEPTION
java.lang.IllegalArgumentException
        at java.nio.Buffer.position(Buffer.java:218)
        at org.mortbay.io.nio.NIOBuffer.poke(NIOBuffer.java:142)
        at org.mortbay.io.AbstractBuffer.put(AbstractBuffer.java:391)
        at org.mortbay.jetty.HttpParser.reset(HttpParser.java:844)
        at org.mortbay.jetty.HttpConnection.destroy(HttpConnection.java:131)
        at org.mortbay.jetty.AbstractConnector.connectionClosed(AbstractConnector.java:785)
        at org.mortbay.jetty.nio.SelectChannelConnector.access$100(SelectChannelConnector.java:64)
        at org.mortbay.jetty.nio.SelectChannelConnector$1.endPointClosed(SelectChannelConnector.java:92)
        at org.mortbay.io.nio.SelectChannelEndPoint.doUpdateKey(SelectChannelEndPoint.java:382)
        at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:337)
        at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:166)
        at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)
        at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:537)



what could be the problem?
LightInTheBox - Buy quality products at wholesale price