Getting IllegalAgrEception while Sending BlobMessage

2010-04-13 Thread ireneshy

Hi , 
I am trying a simple producer and consumer application for BlobMessage, it
works  fine for files of size 8 kb.But if I send file of size more than 64KB
, 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) 

I've tried the code listed in the url:
http://old.nabble.com/Getting-IllegalAgrEception-while-Sending-BlobMessage-td17731668.html#a17731668

But got the same error. Who knows how to fix the problem?


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



Re: Getting IllegalAgrEception while Sending BlobMessage

2010-04-14 Thread ireneshy
 
 private String password = ActiveMQConnection.DEFAULT_PASSWORD;   
   
 private String url =
"tcp://localhost:61616?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:8161/fileserver/";;
   
   
 private String subject = "blob.queue";   
   
 private Destination destination = null;   
   
 private ActiveMQConnection connection = null;   
   
 private ActiveMQSession session = null;   
   
 private MessageConsumer consumer = null; 
   
 // 初始化   
 private void initialize() throws JMSException, Exception {   
 ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(   
 user, password, url);   
 connection =
(ActiveMQConnection)connectionFactory.createConnection();   
 session = (ActiveMQSession)connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);   
 destination = session.createQueue(subject);   
 consumer = session.createConsumer(destination);
 }   
   
 // 消费消息   
 public void consumeMessage() throws JMSException, Exception {   
 initialize();   
 connection.start();   
 // 开始监听  
 System.out.println("Consumer:->Begin listening...");   
 // 设置监听器   
 consumer.setMessageListener(this);   
 // Message message = consumer.receive();   
 }   
   
 // 关闭连接   
 public void close() throws JMSException {   
 System.out.println("Consumer:->Closing connection");   
 if (consumer != null)   
 consumer.close();   
 if (session != null)   
 session.close();   
 if (connection != null)   
 connection.close();   
 }   
   
 // 消息处理函数   
 public void onMessage(Message message) {   
 try {   
 if (message instanceof BlobMessage) {   
 BlobMessage blobMsg = (BlobMessage) message;
 System.out.println("Consumer:->Received: " + blobMsg);
 String fileName = blobMsg.getStringProperty("fileName");
 System.out.println("fileName:"+fileName);
 long fileSize = blobMsg.getLongProperty("fileSize");
 System.out.println("fileSize:"+fileSize+"B");

 InputStream inStr = blobMsg.getInputStream();
  BufferedInputStream bin = new BufferedInputStream(inStr);
 File file = new File("d:/test"+fileName);
 BufferedOutputStream bout = new BufferedOutputStream(new
FileOutputStream(file)); 
 
 byte[] block = new byte[1024];
 while (bin.read(block)!=-1) {   
 bout.write(block); 
 }   
 bout.close();  
 bin.close();
 inStr.close();
 } else { 
 System.out.println("Consumer:->Received: " + message);   
 }   
 } catch (JMSException e) {   
 // TODO Auto-generated catch block   
 e.printStackTrace();   
 } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} 
 }   
 }
3. The test code

 import javax.jms.JMSException;   
   
 public class Test {   
   
public static void main(String[] args) throws JMSException,
Exception {   
 // TODO Auto-generated method stub   
 ConsumerTool consumer = new ConsumerTool();   
 ProducerTool producer = new ProducerTool();   
 // 开始监听   
   consumer.consumeMessage();   

 // 延时500毫秒之后发送消息   
  Thread.sleep(500);   
 producer.produceMessage("d:/1.doc");   
 producer.close();   

 // 延时500毫秒之后停止接受消息   
   Thread.sleep(500);   
 consumer.close();   
   }   
 }



Dejan Bosanac wrote:
> 
> Hi,
> 
> what version are you using and can you post your code?
> 
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Wed, Apr 14, 2010 at 5:11 AM, ireneshy  wrote:
> 
>>
>> Hi ,
>> I am trying a simple producer and consumer application for BlobMessage,
>> it
>> works  fine for files of size 8 kb.But if I send file of size more than
>> 64KB
>> , it throws an exception in the activemq console :
>>
>> ERROR log- EXCEPTION
>> java.lang.IllegalArgumentException
>>at java.nio.Buffer.po

Re: Getting IllegalAgrEception while Sending BlobMessage

2010-04-28 Thread ireneshy

Hi,
 I've been waiting for weeks, is there anything wrong with my code? or
incorrect config?
 Looking forward to your early reply, Thanks a lot~!

Irene



Dejan Bosanac wrote:
> 
> Hi,
> 
> what version are you using and can you post your code?
> 
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Wed, Apr 14, 2010 at 5:11 AM, ireneshy  wrote:
> 
>>
>> Hi ,
>> I am trying a simple producer and consumer application for BlobMessage,
>> it
>> works  fine for files of size 8 kb.But if I send file of size more than
>> 64KB
>> , 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)
>>
>> I've tried the code listed in the url:
>>
>> http://old.nabble.com/Getting-IllegalAgrEception-while-Sending-BlobMessage-td17731668.html#a17731668
>>
>> But got the same error. Who knows how to fix the problem?
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Getting-IllegalAgrEception-while-Sending-BlobMessage-tp28237935p28237935.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

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



How do I deploy the "ActiveMQ-fileserver" webapp into tomcat while using BlobMessage?

2010-05-12 Thread ireneshy

I'm using ActiveMQ BlobMessage to transfer large files, but now I want to set
up ActiveMQ using Tomcat 6.0. I've already configurated the JNDI for the
ConectionFactory and Queue to work within Tomcat. But you know that
BlobMessage must be send to a application that can receive PUT message, and
the default app is fileserver using embedded server Jetty, so how can I
using this fileserver app in Tomcat? Thanks very much for your help~!
-- 
View this message in context: 
http://old.nabble.com/How-do-I-deploy-the-%22ActiveMQ-fileserver%22-webapp-into-tomcat-while-using-BlobMessage--tp28543236p28543236.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Re: How do I deploy the "ActiveMQ-fileserver" webapp into tomcat while using BlobMessage?

2010-05-12 Thread ireneshy

Hi, 
 Thank you very much. Is there any examples about using external FTP
server to store files?
 And another question, how can I clean the files uploaded to the
directory of  "fileserver"  app?
 

Dejan Bosanac wrote:
> 
> Hi,
> 
> there's an open issue for this:
> https://issues.apache.org/activemq/browse/AMQ-2667
> 
> You can try to rewrite it to conform your needs. The alternative is to use
> external FTP server to store files.
> 
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Thu, May 13, 2010 at 5:17 AM, ireneshy  wrote:
> 
>>
>> I'm using ActiveMQ BlobMessage to transfer large files, but now I want to
>> set
>> up ActiveMQ using Tomcat 6.0. I've already configurated the JNDI for the
>> ConectionFactory and Queue to work within Tomcat. But you know that
>> BlobMessage must be send to a application that can receive PUT message,
>> and
>> the default app is fileserver using embedded server Jetty, so how can I
>> using this fileserver app in Tomcat? Thanks very much for your help~!
>> --
>> View this message in context:
>> http://old.nabble.com/How-do-I-deploy-the-%22ActiveMQ-fileserver%22-webapp-into-tomcat-while-using-BlobMessage--tp28543236p28543236.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-deploy-the-%22ActiveMQ-fileserver%22-webapp-into-tomcat-while-using-BlobMessage--tp28543236p28544338.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Re: How do I deploy the "ActiveMQ-fileserver" webapp into tomcat while using BlobMessage?

2010-05-13 Thread ireneshy

Hi,
 Thanks for your help. About deleting files, I've seen code
here:http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/DefaultBlobUploadStrategyTest.java?r=HEAD

I think there is some code that be used for reference:

 BlobTransferPolicy policy = connectionFactory.getBlobTransferPolicy();
 DefaultBlobUploadStrategy strategy = new
DefaultBlobUploadStrategy(policy);
 strategy.deleteFile((ActiveMQBlobMessage)blobMsg);

I've already test these code  in my consumer client, and it works well.
Isn't it a proper way to solve this problem? I doubt.


Dejan Bosanac wrote:
> 
> Hi,
> 
> all you have to do is to define jms.blobTransferPolicy.defaultUploadUrl in
> your broker url, like
> 
> vm://localhost?jms.blobTransferPolicy.defaultUploadUrl=ftp://activemq:activ...@localhost
> /blob
> 
> Take a look at FTPBlobTest for more info
> 
> http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java?r=HEAD
> 
> wrt deleting files, I'm afraid that's one more open issue
> https://issues.apache.org/activemq/browse/AMQ-2713
> 
> <http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java?r=HEAD>
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Thu, May 13, 2010 at 8:50 AM, ireneshy  wrote:
> 
>>
>> Hi,
>> Thank you very much. Is there any examples about using external FTP
>> server to store files?
>> And another question, how can I clean the files uploaded to the
>> directory of  "fileserver"  app?
>>
>>
>> Dejan Bosanac wrote:
>> >
>> > Hi,
>> >
>> > there's an open issue for this:
>> > https://issues.apache.org/activemq/browse/AMQ-2667
>> >
>> > You can try to rewrite it to conform your needs. The alternative is to
>> use
>> > external FTP server to store files.
>> >
>> > Cheers
>> > --
>> > Dejan Bosanac - http://twitter.com/dejanb
>> >
>> > Open Source Integration - http://fusesource.com/
>> > ActiveMQ in Action - http://www.manning.com/snyder/
>> > Blog - http://www.nighttale.net
>> >
>> >
>> > On Thu, May 13, 2010 at 5:17 AM, ireneshy 
>> wrote:
>> >
>> >>
>> >> I'm using ActiveMQ BlobMessage to transfer large files, but now I want
>> to
>> >> set
>> >> up ActiveMQ using Tomcat 6.0. I've already configurated the JNDI for
>> the
>> >> ConectionFactory and Queue to work within Tomcat. But you know that
>> >> BlobMessage must be send to a application that can receive PUT
>> message,
>> >> and
>> >> the default app is fileserver using embedded server Jetty, so how can
>> I
>> >> using this fileserver app in Tomcat? Thanks very much for your help~!
>> >> --
>> >> View this message in context:
>> >>
>> http://old.nabble.com/How-do-I-deploy-the-%22ActiveMQ-fileserver%22-webapp-into-tomcat-while-using-BlobMessage--tp28543236p28543236.html
>> >> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > -
>> > Dejan Bosanac
>> >
>> > Open Source Integration - http://fusesource.com/
>> > ActiveMQ in Action - http://www.manning.com/snyder/
>> > Blog - http://www.nighttale.net
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/How-do-I-deploy-the-%22ActiveMQ-fileserver%22-webapp-into-tomcat-while-using-BlobMessage--tp28543236p28544338.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

-- 
View this message in context: 
http://old.nabble.com/How-do-I-deploy-the-%22ActiveMQ-fileserver%22-webapp-into-tomcat-while-using-BlobMessage--tp28543236p28545226.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Re: How do I deploy the "ActiveMQ-fileserver" webapp into tomcat while using BlobMessage?

2010-05-13 Thread ireneshy

yeah, right. That'll be very convenient for cleaning files after cosuming. We
really appreciate that.


Dejan Bosanac wrote:
> 
> Hi,
> 
> on a second look deleteFile() is not implemented for FTP strategy. I need
> to
> implement it for FTP and make it accessible via ActiveMQBlobMessage
> interface, like
> 
> ((ActiveMQBlobMessage)message).deleteFile();
> 
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Thu, May 13, 2010 at 11:15 AM, Dejan Bosanac 
> wrote:
> 
>> Hi,
>>
>> yeah, this seems like a proper way to do it (I seems to missed it
>> before).
>> So after you consume the message, just use strategy to delete the file.
>> I'll
>> document it later and close the issue. Thanks for the pointer.
>>
>> Cheers
>> --
>> Dejan Bosanac - http://twitter.com/dejanb
>>
>> Open Source Integration - http://fusesource.com/
>> ActiveMQ in Action - http://www.manning.com/snyder/
>> Blog - http://www.nighttale.net
>>
>>
>> On Thu, May 13, 2010 at 10:55 AM, ireneshy  wrote:
>>
>>>
>>> Hi,
>>> Thanks for your help. About deleting files, I've seen code
>>> here:
>>> http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/DefaultBlobUploadStrategyTest.java?r=HEAD
>>>
>>> I think there is some code that be used for reference:
>>>
>>> BlobTransferPolicy policy =
>>> connectionFactory.getBlobTransferPolicy();
>>> DefaultBlobUploadStrategy strategy = new
>>> DefaultBlobUploadStrategy(policy);
>>> strategy.deleteFile((ActiveMQBlobMessage)blobMsg);
>>>
>>> I've already test these code  in my consumer client, and it works well.
>>> Isn't it a proper way to solve this problem? I doubt.
>>>
>>>
>>> Dejan Bosanac wrote:
>>> >
>>> > Hi,
>>> >
>>> > all you have to do is to define
>>> jms.blobTransferPolicy.defaultUploadUrl
>>> in
>>> > your broker url, like
>>> >
>>> >
>>> vm://localhost?jms.blobTransferPolicy.defaultUploadUrl=ftp://activemq:activ...@localhost
>>> > /blob
>>> >
>>> > Take a look at FTPBlobTest for more info
>>> >
>>> >
>>> http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java?r=HEAD
>>> >
>>> > wrt deleting files, I'm afraid that's one more open issue
>>> > https://issues.apache.org/activemq/browse/AMQ-2713
>>> >
>>> > <
>>> http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/blob/FTPBlobTest.java?r=HEAD
>>> >
>>> > Cheers
>>> > --
>>> > Dejan Bosanac - http://twitter.com/dejanb
>>> >
>>> > Open Source Integration - http://fusesource.com/
>>> > ActiveMQ in Action - http://www.manning.com/snyder/
>>> > Blog - http://www.nighttale.net
>>> >
>>> >
>>> > On Thu, May 13, 2010 at 8:50 AM, ireneshy 
>>> wrote:
>>> >
>>> >>
>>> >> Hi,
>>> >> Thank you very much. Is there any examples about using external
>>> FTP
>>> >> server to store files?
>>> >> And another question, how can I clean the files uploaded to the
>>> >> directory of  "fileserver"  app?
>>> >>
>>> >>
>>> >> Dejan Bosanac wrote:
>>> >> >
>>> >> > Hi,
>>> >> >
>>> >> > there's an open issue for this:
>>> >> > https://issues.apache.org/activemq/browse/AMQ-2667
>>> >> >
>>> >> > You can try to rewrite it to conform your needs. The alternative is
>>> to
>>> >> use
>>> >> > external FTP server to store files.
>>> >> >
>>> >> > Cheers
>>> >> > --
>>> >> > Dejan Bosanac - http://twitter.com/dejanb
>>> >> >
>>> >> > Open Source Integration - http://fusesource.com/
>>> >> > ActiveMQ in Action - http://www.manning.com/snyder/
>>> >> > Blog - http://www.nighttale.net
>>> >