You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "tom@hostwebase.com" <to...@hostwebase.com> on 2007/06/21 19:49:35 UTC
How to send file using ActiveMQ
Hi,
Can you let me know how to send large file using ActvieMQ ?
Thanks
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a11238250
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: About Blob Message
Posted by "tom@hostwebase.com" <to...@hostwebase.com>.
Hi,
I just trim down the code, to let it send a file only. In this case, it
shows error pretty clear. Could you look at it for me ?
Here is the code of the RequestTool.java that send big file
//////////////////Start///////////////////////////
try {
activeMQSession = (ActiveMQSession)session;
blobMessage = activeMQSession.createBlobMessage(new
File("/tmp/testFile.exe"));
producer.send(blobMessage);
blobMessage.acknowledge();
System.out.println("Sending message already");
System.out.println("Waiting for reponse message...");
} catch (Exception e) {
System.out.println("Error occur: " + e.getStackTrace());
}
////////////////End//////////////////////////////
Here is the code of the ConsumerTool.java that receive big file
//////////////////Start///////////////////////////
public void onMessage(Message message) {
String temp1, temp2;
byte[] fileData;
File file;
InputStream in;
FileOutputStream fout;
LinkedList dataList;
String fileName;
BlobMessage blobMessage;
ActiveMQSession activeMQSession;
int i;
fileName = "";
fileData = new byte[4096];
try {
if (message instanceof BlobMessage) {
blobMessage = (BlobMessage) message;
in = blobMessage.getInputStream();
fout = new FileOutputStream("/tmp/0/testFile.exe");
while((i = in.read(fileData)) != -1) {
fout.write(fileData, 0, i);
}
fout.close();
}
System.out.println("Already sent file " + fileName);
} catch (Exception e) {
System.out.println("Caught: " + e);
e.printStackTrace();
}
////////////////End//////////////////////////////
When I run the RequestTool and ConsumeTool, I receive errror
//////////////////Start errorMessage on RequestTool side//////////////
Connecting to URL: tcp://192.168.0.227:61616
Publishing a Message with size 1000 to queue: TEST.FOO
Using non-persistent messages
Sleeping between publish 1000 ms
Caught: javax.jms.JMSException: Wire format negotiation timeout: peer did
not send his wire format.
javax.jms.JMSException: Wire format negotiation timeout: peer did not send
his wire format.
at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:58)
at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1215)
at
org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1293)
at
org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:467)
at RequesterTool.run(RequesterTool.java:96)
at RequesterTool.main(RequesterTool.java:77)
Caused by: java.io.IOException: Wire format negotiation timeout: peer did
not send his wire format.
at
org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:88)
at
org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:44)
at
org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:67)
at
org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:72)
at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1205)
... 4 more
/////////////////////////End////////////////////////////////////////////////
//////////////////Start errorMessage on ConsumeTool side//////////////
Connecting to URL: tcp://192.168.0.227:61616
Consuming queue: TEST.FOO
Using a non-durable subscription
Caught: javax.jms.JMSException: Wire format negotiation timeout: peer did
not send his wire format.
javax.jms.JMSException: Wire format negotiation timeout: peer did not send
his wire format.
at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:58)
at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1215)
at
org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1293)
at
org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:467)
at ConsumerTool.run(ConsumerTool.java:98)
at ConsumerTool.main(ConsumerTool.java:81)
Caused by: java.io.IOException: Wire format negotiation timeout: peer did
not send his wire format.
at
org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:88)
at
org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:44)
at
org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:67)
at
org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:72)
at
org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1205)
... 4 more
/////////////////////////End////////////////////////////////////////////////
I have the feeling the main issue is -- Caught: javax.jms.JMSException: Wire
format negotiation timeout: peer did not send his wire format.
Can you show me some example how to use ActiveMQBlobMessage ?
I appreciate you for spending time help me out.
Thanks,
Tom
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a11292303
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: About Blob Message
Posted by James Strachan <ja...@gmail.com>.
On 6/25/07, tom@hostwebase.com <to...@hostwebase.com> wrote:
>
> Hi,
>
> In the java code, when I catch error, I have the code: e.printStackTrace();
> That is all error messages I have on the screen. Do you have any idea ?
I've never seen e.printStackTrace() not generate a stack trace. Are
you sure you're not printing out the contents of e.getStrackTrace()?
--
James
-------
http://macstrac.blogspot.com/
Re: About Blob Message
Posted by "tom@hostwebase.com" <to...@hostwebase.com>.
Hi,
In the java code, when I catch error, I have the code: e.printStackTrace();
That is all error messages I have on the screen. Do you have any idea ?
I appreciate your help.
Thanks
James.Strachan wrote:
>
> On 6/23/07, tom@hostwebase.com <to...@hostwebase.com> wrote:
>>
>> Hi,
>>
>> I still have problem. I appreciate your help.
>>
>> Here is the code that I use to send large file (it's part of the file
>> ConsumerTool.java, it send out file after receiving message from
>> RequestTool.java
>>
>> //////////begin/////////////
>>
>> if (message.getJMSReplyTo() != null) {
>> activeMQSession = (ActiveMQSession)session;
>> message1 = activeMQSession.createBlobMessage(new
>> File("/tmp/0/testFile.exe"));
>> replyProducer.send(message1);
>> message1.acknowledge();
>> }
>
> FWIW you only acknowledge messages you consume.
>
>
>> /////////end////////////////
>>
>>
>> Here is the code that I use to receive large file (it's part of the file
>> RequestTool.java)
>>
>> ////////////begin////////////
>>
>> message1 = consumer.receive();
>> if (message1 instanceof BlobMessage) {
>> blobMessage = (BlobMessage) message1;
>> in = blobMessage.getInputStream();
>> fout = new FileOutputStream("/tmp/testFile.exe");
>> while((i = in.read(fileData)) != -1) {
>> fout.write(fileData, 0, i);
>> }
>> fout.close();
>> } else {
>> System.out.println("Wrong, please send file: ");
>> }
>>
>> ////////////end/////////////
>>
>>
>> This is the error that I receive on the side that receive large file
>> (RequestTool.java)
>>
>> /////////////////////begin////////////////
>>
>> Error occur: [Ljava.lang.StackTraceElement;@187814
>
> No other stack trace?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a11288110
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: About Blob Message
Posted by James Strachan <ja...@gmail.com>.
On 6/23/07, tom@hostwebase.com <to...@hostwebase.com> wrote:
>
> Hi,
>
> I still have problem. I appreciate your help.
>
> Here is the code that I use to send large file (it's part of the file
> ConsumerTool.java, it send out file after receiving message from
> RequestTool.java
>
> //////////begin/////////////
>
> if (message.getJMSReplyTo() != null) {
> activeMQSession = (ActiveMQSession)session;
> message1 = activeMQSession.createBlobMessage(new
> File("/tmp/0/testFile.exe"));
> replyProducer.send(message1);
> message1.acknowledge();
> }
FWIW you only acknowledge messages you consume.
> /////////end////////////////
>
>
> Here is the code that I use to receive large file (it's part of the file
> RequestTool.java)
>
> ////////////begin////////////
>
> message1 = consumer.receive();
> if (message1 instanceof BlobMessage) {
> blobMessage = (BlobMessage) message1;
> in = blobMessage.getInputStream();
> fout = new FileOutputStream("/tmp/testFile.exe");
> while((i = in.read(fileData)) != -1) {
> fout.write(fileData, 0, i);
> }
> fout.close();
> } else {
> System.out.println("Wrong, please send file: ");
> }
>
> ////////////end/////////////
>
>
> This is the error that I receive on the side that receive large file
> (RequestTool.java)
>
> /////////////////////begin////////////////
>
> Error occur: [Ljava.lang.StackTraceElement;@187814
No other stack trace?
--
James
-------
http://macstrac.blogspot.com/
Re: About Blob Message
Posted by "tom@hostwebase.com" <to...@hostwebase.com>.
Hi,
I still have problem. I appreciate your help.
Here is the code that I use to send large file (it's part of the file
ConsumerTool.java, it send out file after receiving message from
RequestTool.java
//////////begin/////////////
if (message.getJMSReplyTo() != null) {
activeMQSession = (ActiveMQSession)session;
message1 = activeMQSession.createBlobMessage(new
File("/tmp/0/testFile.exe"));
replyProducer.send(message1);
message1.acknowledge();
}
/////////end////////////////
Here is the code that I use to receive large file (it's part of the file
RequestTool.java)
////////////begin////////////
message1 = consumer.receive();
if (message1 instanceof BlobMessage) {
blobMessage = (BlobMessage) message1;
in = blobMessage.getInputStream();
fout = new FileOutputStream("/tmp/testFile.exe");
while((i = in.read(fileData)) != -1) {
fout.write(fileData, 0, i);
}
fout.close();
} else {
System.out.println("Wrong, please send file: ");
}
////////////end/////////////
This is the error that I receive on the side that receive large file
(RequestTool.java)
/////////////////////begin////////////////
Error occur: [Ljava.lang.StackTraceElement;@187814
Done.
connection {
session {
messageCount{ count: 0 unit: count startTime: 1182554060219
lastSampleTime: 1182554060219 description: Number of messages exchanged }
messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060220
lastSampleTime: 1182554060220 description: Time taken to process a message
(thoughtput rate) }
pendingMessageCount{ count: 0 unit: count startTime: 1182554060219
lastSampleTime: 1182554060219 description: Number of pending messages }
expiredMessageCount{ count: 0 unit: count startTime: 1182554060219
lastSampleTime: 1182554060219 description: Number of expired messages }
messageWaitTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060219
lastSampleTime: 1182554060219 description: Time spent by a message before
being delivered }
durableSubscriptionCount{ count: 0 unit: count startTime: 1182554060219
lastSampleTime: 1182554060219 description: The number of durable
subscriptions }
producers {
producer queue://TEST.FOO {
messageCount{ count: 0 unit: count startTime: 1182554060244
lastSampleTime: 1182554060244 description: Number of messages processed }
messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060244
lastSampleTime: 1182554060244 description: Time taken to process a message
(thoughtput rate) }
pendingMessageCount{ count: 0 unit: count startTime: 1182554060244
lastSampleTime: 1182554060244 description: Number of pending messages }
messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060244
lastSampleTime: 1182554060244 description: Time taken to process a message
(thoughtput rate) }
expiredMessageCount{ count: 0 unit: count startTime: 1182554060244
lastSampleTime: 1182554060244 description: Number of expired messages }
messageWaitTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060244
lastSampleTime: 1182554060244 description: Time spent by a message before
being delivered }
}
}
consumers {
consumer queue://TEST.FOO1 {
messageCount{ count: 0 unit: count startTime: 1182554060258
lastSampleTime: 1182554060258 description: Number of messages processed }
messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060258
lastSampleTime: 1182554060258 description: Time taken to process a message
(thoughtput rate) }
pendingMessageCount{ count: 0 unit: count startTime: 1182554060258
lastSampleTime: 1182554060258 description: Number of pending messages }
messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060258
lastSampleTime: 1182554060258 description: Time taken to process a message
(thoughtput rate) }
expiredMessageCount{ count: 0 unit: count startTime: 1182554060258
lastSampleTime: 1182554060258 description: Number of expired messages }
messageWaitTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1182554060258
lastSampleTime: 1182554060258 description: Time spent by a message before
being delivered }
}
}
}
}
////////////////end/////////////////////
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a11261565
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: About Blob Message
Posted by James Strachan <ja...@gmail.com>.
On 6/22/07, tom@hostwebase.com <to...@hostwebase.com> wrote:
>
>
> At the web page with URL http://activemq.apache.org/blob-messages.html , it
> only shows briefly how to send, but it doesn't show how to receive BLOB
> messages. Can you show me the web pages that show how to receive BLOB
> messages?
See
http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/BlobMessage.html
All JMS messages are received in the same way.
public class MyListener implements MessageListener {
public void onMessage(Message message) {
if (message instanceof BlobMessage) {
BlobMessage blobMessage = (BlobMessage) message;
InputStream in = blobMessage.getInputStream();
// process the stream...
}
}
}
>
> Thanks a lot
> --
> View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a11253564
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
About Blob Message
Posted by "tom@hostwebase.com" <to...@hostwebase.com>.
At the web page with URL http://activemq.apache.org/blob-messages.html , it
only shows briefly how to send, but it doesn't show how to receive BLOB
messages. Can you show me the web pages that show how to receive BLOB
messages?
Thanks a lot
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a11253564
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: How to send file using ActiveMQ
Posted by James Strachan <ja...@gmail.com>.
On 6/21/07, tom@hostwebase.com <to...@hostwebase.com> wrote:
>
> Hi,
>
> Can you let me know how to send large file using ActvieMQ ?
Yes. We've supported JMS streams for a few years now, though in 5.x
there's an even better mechanism, Blob Messages which supports out of
band and external file systems/web servers
http://activemq.apache.org/blob-messages.html
--
James
-------
http://macstrac.blogspot.com/
Re: How to send file using ActiveMQ
Posted by Sherif <sh...@hotmail.com>.
Try setting the copyMessageOnWrite option to false. I know it's not a good
idea to do that, but it's the only way I got it to make it work.
I'm supposing that this is not normal behavior and that maybe this issue
will be fixed.
ttmdev wrote:
>
> I am trying to use the BlobMessage to send a file directly from producer
> to consumer.
>
> All works fine, the BlogMessage message is sent from producer to
> consumer;except, the consumer always gets a NULL InputStream when it
> invokes BlobMessage.getInputStream();
>
> My BLOB transfer policy is set as follows @ both ends.
>
> jms.blobTransferPolicy.uploadUrl=http://xx.xx.230.189/uploads
>
> I never see the file on the file server at xx.xx.230.189/uploads.
>
> What am I missing?
>
> Thanks!
>
>
> James.Strachan wrote:
>>
>> On 6/21/07, Gaurav Hariani <ga...@blackspark.com> wrote:
>>> We have a similar need and after trying a number of approaches we
>>> settled on the following approach:
>>>
>>> The producer creates a file in a directory where it can be served by a
>>> webserver e.g. ~gaurav/public_html/large_messages/xyzABC123.zip
>>> Then the producer sends the URL of this file as a text message
>>> http://server/~gaurav/public_html/large_messages/xyzABC123.zip
>>> Consumers read the message and retrieve the file using the contained
>>> URL.
>>> After a specified interval the producer cleans up the files it has
>>> produced (you could change this policy depending on your specific needs)
>>
>> BTW the BlobMessage is a nicer option; as it allows you to send files
>> directly from the producer; or to pass a remote URL of the file. From
>> the consumer side it doesn't know the difference; its just a URL to
>> download etc
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>>
>
>
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a12831498
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: How to send file using ActiveMQ
Posted by ttmdev <jo...@ttmsolutions.com>.
I am trying to use the BlobMessage to send a file directly from producer to
consumer.
All works fine, the BlogMessage message is sent from producer to
consumer;except, the consumer always gets a NULL InputStream when it invokes
BlobMessage.getInputStream();
My BLOB transfer policy is set as follows @ both ends.
jms.blobTransferPolicy.uploadUrl=http://xx.xx.230.189/uploads
I never see the file on the file server at xx.xx.230.189/uploads.
What am I missing?
Thanks!
James.Strachan wrote:
>
> On 6/21/07, Gaurav Hariani <ga...@blackspark.com> wrote:
>> We have a similar need and after trying a number of approaches we
>> settled on the following approach:
>>
>> The producer creates a file in a directory where it can be served by a
>> webserver e.g. ~gaurav/public_html/large_messages/xyzABC123.zip
>> Then the producer sends the URL of this file as a text message
>> http://server/~gaurav/public_html/large_messages/xyzABC123.zip
>> Consumers read the message and retrieve the file using the contained URL.
>> After a specified interval the producer cleans up the files it has
>> produced (you could change this policy depending on your specific needs)
>
> BTW the BlobMessage is a nicer option; as it allows you to send files
> directly from the producer; or to pass a remote URL of the file. From
> the consumer side it doesn't know the difference; its just a URL to
> download etc
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/How-to-send-file-using-ActiveMQ-tf3960326s2354.html#a12803896
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: How to send file using ActiveMQ
Posted by James Strachan <ja...@gmail.com>.
On 6/21/07, Gaurav Hariani <ga...@blackspark.com> wrote:
> We have a similar need and after trying a number of approaches we
> settled on the following approach:
>
> The producer creates a file in a directory where it can be served by a
> webserver e.g. ~gaurav/public_html/large_messages/xyzABC123.zip
> Then the producer sends the URL of this file as a text message
> http://server/~gaurav/public_html/large_messages/xyzABC123.zip
> Consumers read the message and retrieve the file using the contained URL.
> After a specified interval the producer cleans up the files it has
> produced (you could change this policy depending on your specific needs)
BTW the BlobMessage is a nicer option; as it allows you to send files
directly from the producer; or to pass a remote URL of the file. From
the consumer side it doesn't know the difference; its just a URL to
download etc
--
James
-------
http://macstrac.blogspot.com/
Re: How to send file using ActiveMQ
Posted by Gaurav Hariani <ga...@blackspark.com>.
We have a similar need and after trying a number of approaches we
settled on the following approach:
The producer creates a file in a directory where it can be served by a
webserver e.g. ~gaurav/public_html/large_messages/xyzABC123.zip
Then the producer sends the URL of this file as a text message
http://server/~gaurav/public_html/large_messages/xyzABC123.zip
Consumers read the message and retrieve the file using the contained URL.
After a specified interval the producer cleans up the files it has
produced (you could change this policy depending on your specific needs)
tom@hostwebase.com wrote:
> Hi,
>
> Can you let me know how to send large file using ActvieMQ ?
>
> Thanks
>
Re: How to send file using ActiveMQ
Posted by Kit Plummer <ch...@raytheon.com>.
We're using JMS to carry 100-1000MB files.
tom@hostwebase.com wrote:
> Hi,
>
> Can you let me know how to send large file using ActvieMQ ?
>
> Thanks