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/22 16:39:41 UTC

About Blob Message


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: 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/