You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "rain.xk" <ra...@gmail.com> on 2006/07/08 05:50:06 UTC

Re: ActiveMQ Outputstream message properties

Hi,
When I receive the Message,How can I get the myMap Info?
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5227800
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by "rain.xk" <ra...@gmail.com>.
Hi,
I try in your way ,I can get the message property ,but I get a 0kb file.
I check the database the stream message have 3 rows, but I just receive 1
row in your way.
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5233212
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by ychawla <pr...@yahoo.com>.
Again, I apologize, I have updated code at work which I did not check in so I
can not access now.  This should work to read the BytesMessage.  The last
message in the sequence will be, I think, a StreamMessage with a group
sequence of -1 and this will indicate to you that you are at the end of your
file and you can close the stream.

ActiveMQInputStream streamMsg = (ActiveMQInputStream
)connection.createInputStream();
ActiveMQMessage message = streamMsg.receive();
message.getStringProperty("fileName"); 
ByteSequence bs = ((ActiveMQBytesMessage)message).getContent();
fos.write(bs.getData()); 


-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5233075
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by "rain.xk" <ra...@gmail.com>.
Hi,
If I use this way:
ActiveMQInputStream streamMsg = (ActiveMQInputStream
)connection.createInputStream();
ActiveMQMessage message = streamMsg.receive();
message.getStringProperty("fileName");

I can get the property,but I can not get the stream message.

can you show me your whole code about the stream message with property?
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5233013
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by ychawla <pr...@yahoo.com>.
I read the messages using a message driven POJO in Spring 2.0.  The
ActiveMQBytesMessage extends an ActiveMQMessage so you can use the methods
available in ActiveMQMessage, such as getStringProperty,  to read the
message properties.  I have my code at work but I think this is an example
that might be helpful:

		if (message instanceof BytesMessage) {
			try {
				log.debug("This is the message type:" + message.getJMSType() + "\n\n" +
message);

//HERE YOU ARE GETTING A PROPERTY 
				log.debug("This is the invocation property" +
message.getStringProperty("invocation") + "\n\n" + message);
				

messageId = ((ActiveMQBytesMessage)message).getGroupID();
				ByteSequence bs = ((ActiveMQBytesMessage)message).getContent();
				
				fos.write(bs.getData());

			} catch (JMSException e) {
				throw new RuntimeException(e);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
		}
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5232815
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by ychawla <pr...@yahoo.com>.
With the code sample you posted, you can probably also do something like
this... I have my code at work so I will check this out on Monday.

ActiveMQInputStream streamMsg = (ActiveMQInputStream
)connection.createInputStream();

ActiveMQMessage message = streamMsg.receive();
message.getStringProperty("fileName");
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5232880
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by "rain.xk" <ra...@gmail.com>.
i receive stream message like this:
ActiveMQInputStream streamMsg = (ActiveMQInputStream
)connection.createInputStream();
FileWrite file = new FileWrite("d:\temp.rar", 0);
while ((byteread = streamMsg.read(buffer)) != -1) {
	log.info("get file now======");
	file.write(buffer, 0, byteread);
}

how can i get the message property?
Or I can get the stream message by another way ?
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5232663
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ Outputstream message properties

Posted by ychawla <pr...@yahoo.com>.
To retrieve the message, you can get the properties you set.  For example, I
added an entry called 'invocation' to my map and retrieve it using
'message.getStringProperty':

invocationType = message.getStringProperty("invocation");
-- 
View this message in context: http://www.nabble.com/ActiveMQ-Outputstream-message-properties-tf1807819.html#a5232553
Sent from the ActiveMQ - User forum at Nabble.com.