activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iosev Perez Rivero" <iper...@uci.cu>
Subject RE: problem with blobmessage in activemq 5.0
Date Mon, 25 Feb 2008 04:53:15 GMT
I not use put command, this is the complete code:

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory; import javax.jms.QueueSession; 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.ActiveMQBlobMessage;
import org.apache.activemq.command.ActiveMQQueue;
public class Sending {
 /**
  * @param args
  * @throws IOException
  */
 public static void main(String[] args) throws IOException {
  // TODO Auto-generated method stub
  long a1 = System.currentTimeMillis();
  ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(
    "tcp://localhost:61616");
  ActiveMQConnection conn = null;
  ActiveMQSession session = null;
  try {
   conn = (ActiveMQConnection)cf.createConnection();
   session = (ActiveMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Destination destination = new ActiveMQQueue("Queue");
   MessageProducer producer = session.createProducer(destination);
   
   BlobMessage message = session.createBlobMessage(new File("src\\BlobMessage\\file\\foto.jpg"));
   
   System.out.println(message.getInputStream());
   
   producer.send(message);
  } catch (JMSException e) {
   e.printStackTrace();
  } finally {
   try {
    if (session != null) {
     session.close();
    }
    if (conn != null) {
     conn.close();
    }
   } catch (JMSException ex) {
   }
  }
  a1 = System.currentTimeMillis() - a1;
  System.out.println(a1);
 }
}

Ing. Iósev Pérez Rivero
Dirección Técnica - IP
Universidad de las Ciencias Informáticas

-----Original Message-----
From: Marco Buss [mailto:marco.buss@gmx.de] 
Sent: Sunday, February 24, 2008 8:42 AM
To: users@activemq.apache.org
Subject: Re: problem with blobmessage in activemq 5.0

Iosev Perez Rivero schrieb:
> When i create blobmessage object and print the inputstream, printed NULL, why??? then
when i send the message the file not sending, the message sending empty.
>
>  
>
> Please may anybody help me??
>
>  
>
> Here is code:
>
>  
>
>    conn = (ActiveMQConnection)cf.createConnection();
>
>    session = (ActiveMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>
>    Destination destination = new ActiveMQQueue("Queue");
>
>    MessageProducer producer = session.createProducer(destination);
>
>    
>
>    BlobMessage message = session.createBlobMessage(new File("src\\BlobMessage\\file\\foto.jpg"));
>
>    
>
>    System.out.println(message.getInputStream());
>
>    
>
>    producer.send(message);
>
>  
>
>  
>
>  
>
> Ing. Iósev Pérez Rivero
>
> Dirección Técnica - IP
>
> Universidad de las Ciencias Informáticas
>
>  
>
>
>   
Hello.

What ist you initialisation URL? Did you run the Fileserver webapp or an 
Server wich supports the put command?

Mime
View raw message