You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by brownm_uk <br...@yahoo.co.uk> on 2010/11/02 11:57:35 UTC

MapMessage - theTable empty when receiving

I've just installed version 5.4.1 on Windows and altered the ProducerTool
example source code to produce MapMessages instead of TextMessages (patch
for ProducerTool.java at end of this email).  When I run the producer &
consumer pair from Ant as per the usual instructions, I see the 'produced'
messages contain the right data in 'theTable' ...

     [java] [Thread-2] Sending message: 'ActiveMQMapMessage {commandId = 0,
responseRequired = false, messageId = null, originalDestination = null,
originalTransactionId = null, producerId = null, destination = null,
transactionId = null, expiration = 0, timestamp = 0, arrival = 0,
brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null,
persistent = false, type = null, priority = 0, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
null, marshalledProperties = null, dataStructure = null, redeliveryCounter =
0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody =
false, droppable = false} ActiveMQMapMessage{ theTable = {id=0} }'

but in the 'consumed' messages 'theTable' appears empty ...

     [java] [Thread-2] Received: 'ActiveMQMapMessage {commandId = 5,
responseRequired = false, messageId =
ID:pcdelldevmb-64173-1288693987697-0:0:1:1:1, originalDestination = null,
originalTransactionId = null, producerId =
ID:pcdelldevmb-64173-1288693987697-0:0:1:1, destination = queue://TEST.FOO,
transactionId = null, expiration = 0, timestamp = 1288693988050, arrival =
0, brokerInTime = 1288693988050, brokerOutTime = 1288693988051,
correlationId = null, replyTo = null, persistent = false, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@1d225a7, marshalledProperties = null,
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null,
readOnlyProperties = true, readOnlyBody = true, droppable = false}
ActiveMQMapMessage{ theTable = {} }'


Any ideas as to why this is happening and how I can receive the correct Map
data in a MapMessage?

Thanks in advance,
Martin Brown




--- ProducerTool.java.orig	2010-11-01 15:41:11.746392100 +0000
+++ ProducerTool.java	2010-11-02 08:58:59.572244500 +0000
@@ -22,6 +22,7 @@
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
+import javax.jms.MapMessage;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
@@ -154,14 +155,17 @@
 
         for (int i = 0; i < messageCount || messageCount == 0; i++) {
 
-            TextMessage message =
session.createTextMessage(createMessageText(i));
+            // TextMessage message =
session.createTextMessage(createMessageText(i));
+            MapMessage message = session.createMapMessage();
+	    message.setInt("id", i);
 
             if (verbose) {
-                String msg = message.getText();
-                if (msg.length() > 50) {
-                    msg = msg.substring(0, 50) + "...";
-                }
-                System.out.println("[" + this.getName() + "] Sending
message: '" + msg + "'");
+                // String msg = message.getText();
+                // if (msg.length() > 50) {
+                //     msg = msg.substring(0, 50) + "...";
+                // }
+                // System.out.println("[" + this.getName() + "] Sending
message: '" + msg + "'");
+                System.out.println("[" + this.getName() + "] Sending
message: '" + message + "'");
             }
 
             producer.send(message);


-- 
View this message in context: http://activemq.2283324.n4.nabble.com/MapMessage-theTable-empty-when-receiving-tp3023521p3023521.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: MapMessage - theTable empty when receiving

Posted by Gary Tully <ga...@gmail.com>.
note that on the sent message the content=null, on the received
message the content is a valid byte sequence.
The map will be unmarshalled from the byte array as part of the first
get opeation on the map message.

On 2 November 2010 10:57, brownm_uk <br...@yahoo.co.uk> wrote:
>
> I've just installed version 5.4.1 on Windows and altered the ProducerTool
> example source code to produce MapMessages instead of TextMessages (patch
> for ProducerTool.java at end of this email).  When I run the producer &
> consumer pair from Ant as per the usual instructions, I see the 'produced'
> messages contain the right data in 'theTable' ...
>
>     [java] [Thread-2] Sending message: 'ActiveMQMapMessage {commandId = 0,
> responseRequired = false, messageId = null, originalDestination = null,
> originalTransactionId = null, producerId = null, destination = null,
> transactionId = null, expiration = 0, timestamp = 0, arrival = 0,
> brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null,
> persistent = false, type = null, priority = 0, groupID = null, groupSequence
> = 0, targetConsumerId = null, compressed = false, userID = null, content =
> null, marshalledProperties = null, dataStructure = null, redeliveryCounter =
> 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody =
> false, droppable = false} ActiveMQMapMessage{ theTable = {id=0} }'
>
> but in the 'consumed' messages 'theTable' appears empty ...
>
>     [java] [Thread-2] Received: 'ActiveMQMapMessage {commandId = 5,
> responseRequired = false, messageId =
> ID:pcdelldevmb-64173-1288693987697-0:0:1:1:1, originalDestination = null,
> originalTransactionId = null, producerId =
> ID:pcdelldevmb-64173-1288693987697-0:0:1:1, destination = queue://TEST.FOO,
> transactionId = null, expiration = 0, timestamp = 1288693988050, arrival =
> 0, brokerInTime = 1288693988050, brokerOutTime = 1288693988051,
> correlationId = null, replyTo = null, persistent = false, type = null,
> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
> compressed = false, userID = null, content =
> org.apache.activemq.util.ByteSequence@1d225a7, marshalledProperties = null,
> dataStructure = null, redeliveryCounter = 0, size = 0, properties = null,
> readOnlyProperties = true, readOnlyBody = true, droppable = false}
> ActiveMQMapMessage{ theTable = {} }'
>
>
> Any ideas as to why this is happening and how I can receive the correct Map
> data in a MapMessage?
>
> Thanks in advance,
> Martin Brown
>
>
>
>
> --- ProducerTool.java.orig      2010-11-01 15:41:11.746392100 +0000
> +++ ProducerTool.java   2010-11-02 08:58:59.572244500 +0000
> @@ -22,6 +22,7 @@
>  import javax.jms.Connection;
>  import javax.jms.DeliveryMode;
>  import javax.jms.Destination;
> +import javax.jms.MapMessage;
>  import javax.jms.MessageProducer;
>  import javax.jms.Session;
>  import javax.jms.TextMessage;
> @@ -154,14 +155,17 @@
>
>         for (int i = 0; i < messageCount || messageCount == 0; i++) {
>
> -            TextMessage message =
> session.createTextMessage(createMessageText(i));
> +            // TextMessage message =
> session.createTextMessage(createMessageText(i));
> +            MapMessage message = session.createMapMessage();
> +           message.setInt("id", i);
>
>             if (verbose) {
> -                String msg = message.getText();
> -                if (msg.length() > 50) {
> -                    msg = msg.substring(0, 50) + "...";
> -                }
> -                System.out.println("[" + this.getName() + "] Sending
> message: '" + msg + "'");
> +                // String msg = message.getText();
> +                // if (msg.length() > 50) {
> +                //     msg = msg.substring(0, 50) + "...";
> +                // }
> +                // System.out.println("[" + this.getName() + "] Sending
> message: '" + msg + "'");
> +                System.out.println("[" + this.getName() + "] Sending
> message: '" + message + "'");
>             }
>
>             producer.send(message);
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/MapMessage-theTable-empty-when-receiving-tp3023521p3023521.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
http://blog.garytully.com
http://fusesource.com