activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fancellu <d...@felstar.com>
Subject Cannonical class to receive file?
Date Wed, 20 Dec 2006 13:24:45 GMT

I see http://www.activemq.org/site/jms-streams.html

So I write a sample prog:

ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(url);
ActiveMQConnection  connection = (ActiveMQConnection
)connectionFactory.createConnection();              
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(q);

Map props=new HashMap();        	
props.put("filename",file.getName());
OutputStream out =
connection.createOutputStream(destination,props,DeliveryMode.NON_PERSISTENT,ActiveMQMessage.DEFAULT_PRIORITY,ActiveMQMessage.DEFAULT_TIME_TO_LIVE);
copy(new FileInputStream(file),out);     	
out.flush();
out.close();

This seems to work, taking a 3.3MB file, it sets the queue size to 55, and
via JMX I see BrowseMessages shows 1 message, as browseAsTable shows lots of
CompositeData[] records.

Now the problem is receiving the file. It appears to arrive as lots of
little ActiveMQBytesMessage messages,
which is odd as I expected one message, as shown via BrowseMessages.

I'd rather I took it as one message with an inputstream I can read from. Is
this possible?

What is the canoncial piece of code to receive the 3.3MB file and write it
down to disk?

Thanks.
-- 
View this message in context: http://www.nabble.com/Cannonical-class-to-receive-file--tf2859754.html#a7989989
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message