You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Viali.Lee" <Vi...@Hotmail.COM> on 2007/08/09 14:56:59 UTC
BlobMessage feature doesn't work...
I download the ActiveMQ 5.0-SNAPSHOT and unzip it, then run
/bin/activemq.bat.
After that, I wrote a Producer and Consumer to test the BlobMessage feature
of ActiveMQ 5.0-SNAPSHOT, but failed!!!
Producer.java:
import java.io.File;
import javax.jms.*;
import org.apache.activemq.*;
public class Producer
{
public static void main(String[] args) throws Exception
{
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
connection.start();
ActiveMQSession session = (ActiveMQSession)
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("message.larger.input");
MessageProducer producer = session.createProducer(destination);
BlobMessage message = session.createBlobMessage(new
File("D://1.1K.Test.xml"));
producer.send(message);
session.close();
connection.close();
}
}
Consumer.java:
import java.io.*;
import javax.jms.*;
import javax.jms.Message;
import org.apache.activemq.*;
public class Consumer
{
public static void main(String[] args) throws Exception
{
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
connection.start();
ActiveMQSession session = (ActiveMQSession)
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("message.larger.input");
MessageConsumer consumer = session.createConsumer(destination);
Message message = consumer.receive(10000);
BlobMessage blobMessage = (BlobMessage) message;
InputStream in = blobMessage.getInputStream();
byte[] b = new byte[2048];
File file = new File("D://result.xml");
FileOutputStream out = new FileOutputStream(file);
while (in.read(b) > 0) {
out.write(b);
}
out.close();
session.close();
connection.close();
}
}
error:
Exception in thread "main" java.lang.NullPointerException
the inputstream received by Consumer is null.
who knows what happened??
--
View this message in context: http://www.nabble.com/BlobMessage-feature-doesn%27t-work...-tf4242464s2354.html#a12071923
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: BlobMessage feature doesn't work...
Posted by "Viali.Lee" <Vi...@Hotmail.COM>.
URL = null
java.lang.NullPointerException
at Consumer.main(Consumer.java:25)---(IN)
thanks for your reply. I am not sure the URL and the stacktrace would help,
I think you can have a try in you computer.....
James.Strachan wrote:
>
> Could you print the full stack trace; also show the getURL() value in
> the blobMessage?
>
>
> On 8/9/07, Viali.Lee <Vi...@hotmail.com> wrote:
>>
>> I download the ActiveMQ 5.0-SNAPSHOT and unzip it, then run
>> /bin/activemq.bat.
>> After that, I wrote a Producer and Consumer to test the BlobMessage
>> feature
>> of ActiveMQ 5.0-SNAPSHOT, but failed!!!
>>
>> Producer.java:
>>
>> import java.io.File;
>> import javax.jms.*;
>> import org.apache.activemq.*;
>> public class Producer
>> {
>> public static void main(String[] args) throws Exception
>> {
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory("tcp://localhost:61616");
>> Connection connection =
>> connectionFactory.createConnection();
>> connection.start();
>> ActiveMQSession session = (ActiveMQSession)
>> connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>> Destination destination =
>> session.createQueue("message.larger.input");
>> MessageProducer producer =
>> session.createProducer(destination);
>> BlobMessage message = session.createBlobMessage(new
>> File("D://1.1K.Test.xml"));
>> producer.send(message);
>> session.close();
>> connection.close();
>> }
>> }
>>
>>
>> Consumer.java:
>>
>> import java.io.*;
>> import javax.jms.*;
>> import javax.jms.Message;
>> import org.apache.activemq.*;
>> public class Consumer
>> {
>> public static void main(String[] args) throws Exception
>> {
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory("tcp://localhost:61616");
>> Connection connection =
>> connectionFactory.createConnection();
>> connection.start();
>> ActiveMQSession session = (ActiveMQSession)
>> connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>> Destination destination =
>> session.createQueue("message.larger.input");
>> MessageConsumer consumer =
>> session.createConsumer(destination);
>> Message message = consumer.receive(10000);
>>
>> BlobMessage blobMessage = (BlobMessage) message;
>> InputStream in = blobMessage.getInputStream();
>> byte[] b = new byte[2048];
>> File file = new File("D://result.xml");
>> FileOutputStream out = new FileOutputStream(file);
>> while (in.read(b) > 0) {
>> out.write(b);
>> }
>> out.close();
>> session.close();
>> connection.close();
>> }
>> }
>>
>> error:
>> Exception in thread "main" java.lang.NullPointerException
>> the inputstream received by Consumer is null.
>>
>> who knows what happened??
>> --
>> View this message in context:
>> http://www.nabble.com/BlobMessage-feature-doesn%27t-work...-tf4242464s2354.html#a12071923
>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>
>>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/BlobMessage-feature-doesn%27t-work...-tf4242464s2354.html#a12073366
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: BlobMessage feature doesn't work...Bug ??
Posted by "Viali.Lee" <Vi...@Hotmail.COM>.
I've try the new snapshot of apache-activemq-5.0-20070809.221110-48..
But still not work...
is it a bug ?
James.Strachan wrote:
>
> Could you print the full stack trace; also show the getURL() value in
> the blobMessage?
>
>
> On 8/9/07, Viali.Lee <Vi...@hotmail.com> wrote:
>>
>> I download the ActiveMQ 5.0-SNAPSHOT and unzip it, then run
>> /bin/activemq.bat.
>> After that, I wrote a Producer and Consumer to test the BlobMessage
>> feature
>> of ActiveMQ 5.0-SNAPSHOT, but failed!!!
>>
>> Producer.java:
>>
>> import java.io.File;
>> import javax.jms.*;
>> import org.apache.activemq.*;
>> public class Producer
>> {
>> public static void main(String[] args) throws Exception
>> {
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory("tcp://localhost:61616");
>> Connection connection =
>> connectionFactory.createConnection();
>> connection.start();
>> ActiveMQSession session = (ActiveMQSession)
>> connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>> Destination destination =
>> session.createQueue("message.larger.input");
>> MessageProducer producer =
>> session.createProducer(destination);
>> BlobMessage message = session.createBlobMessage(new
>> File("D://1.1K.Test.xml"));
>> producer.send(message);
>> session.close();
>> connection.close();
>> }
>> }
>>
>>
>> Consumer.java:
>>
>> import java.io.*;
>> import javax.jms.*;
>> import javax.jms.Message;
>> import org.apache.activemq.*;
>> public class Consumer
>> {
>> public static void main(String[] args) throws Exception
>> {
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory("tcp://localhost:61616");
>> Connection connection =
>> connectionFactory.createConnection();
>> connection.start();
>> ActiveMQSession session = (ActiveMQSession)
>> connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>> Destination destination =
>> session.createQueue("message.larger.input");
>> MessageConsumer consumer =
>> session.createConsumer(destination);
>> Message message = consumer.receive(10000);
>>
>> BlobMessage blobMessage = (BlobMessage) message;
>> InputStream in = blobMessage.getInputStream();
>> byte[] b = new byte[2048];
>> File file = new File("D://result.xml");
>> FileOutputStream out = new FileOutputStream(file);
>> while (in.read(b) > 0) {
>> out.write(b);
>> }
>> out.close();
>> session.close();
>> connection.close();
>> }
>> }
>>
>> error:
>> Exception in thread "main" java.lang.NullPointerException
>> the inputstream received by Consumer is null.
>>
>> who knows what happened??
>> --
>> View this message in context:
>> http://www.nabble.com/BlobMessage-feature-doesn%27t-work...-tf4242464s2354.html#a12071923
>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>
>>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/BlobMessage-feature-doesn%27t-work...-tf4242464s2354.html#a12087094
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: BlobMessage feature doesn't work...
Posted by James Strachan <ja...@gmail.com>.
Could you print the full stack trace; also show the getURL() value in
the blobMessage?
On 8/9/07, Viali.Lee <Vi...@hotmail.com> wrote:
>
> I download the ActiveMQ 5.0-SNAPSHOT and unzip it, then run
> /bin/activemq.bat.
> After that, I wrote a Producer and Consumer to test the BlobMessage feature
> of ActiveMQ 5.0-SNAPSHOT, but failed!!!
>
> Producer.java:
>
> import java.io.File;
> import javax.jms.*;
> import org.apache.activemq.*;
> public class Producer
> {
> public static void main(String[] args) throws Exception
> {
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://localhost:61616");
> Connection connection = connectionFactory.createConnection();
> connection.start();
> ActiveMQSession session = (ActiveMQSession)
> connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> Destination destination = session.createQueue("message.larger.input");
> MessageProducer producer = session.createProducer(destination);
> BlobMessage message = session.createBlobMessage(new
> File("D://1.1K.Test.xml"));
> producer.send(message);
> session.close();
> connection.close();
> }
> }
>
>
> Consumer.java:
>
> import java.io.*;
> import javax.jms.*;
> import javax.jms.Message;
> import org.apache.activemq.*;
> public class Consumer
> {
> public static void main(String[] args) throws Exception
> {
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://localhost:61616");
> Connection connection = connectionFactory.createConnection();
> connection.start();
> ActiveMQSession session = (ActiveMQSession)
> connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> Destination destination = session.createQueue("message.larger.input");
> MessageConsumer consumer = session.createConsumer(destination);
> Message message = consumer.receive(10000);
>
> BlobMessage blobMessage = (BlobMessage) message;
> InputStream in = blobMessage.getInputStream();
> byte[] b = new byte[2048];
> File file = new File("D://result.xml");
> FileOutputStream out = new FileOutputStream(file);
> while (in.read(b) > 0) {
> out.write(b);
> }
> out.close();
> session.close();
> connection.close();
> }
> }
>
> error:
> Exception in thread "main" java.lang.NullPointerException
> the inputstream received by Consumer is null.
>
> who knows what happened??
> --
> View this message in context: http://www.nabble.com/BlobMessage-feature-doesn%27t-work...-tf4242464s2354.html#a12071923
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/