diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java index bb6ec38284..5f47bcbc01 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java @@ -570,6 +570,7 @@ public class ProtocolConverter { } else if( message.getDataStructureType() == ActiveMQBytesMessage.DATA_STRUCTURE_TYPE ) { ActiveMQBytesMessage msg = (ActiveMQBytesMessage)message.copy(); + msg.setReadOnlyBody(true); byte[] data = new byte[(int)msg.getBodyLength()]; msg.readBytes(data); diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java index a4ea630b4c..3e5863bbb7 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java @@ -20,6 +20,8 @@ package org.apache.activemq.transport.stomp; import java.io.IOException; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; import javax.jms.JMSException; @@ -91,18 +93,23 @@ public class StompSubscription { ack.setConsumerId(consumerInfo.getConsumerId()); int count=0; - for (Iterator iter = dispatchedMessage.keySet().iterator(); iter.hasNext();) { + for (Iterator iter = dispatchedMessage.entrySet().iterator(); iter.hasNext();) { + + Map.Entry entry = (Entry) iter.next(); + String id = (String) entry.getKey(); + MessageId msgid = (MessageId) entry.getValue(); - String id = (String) iter.next(); if( ack.getFirstMessageId()==null ) - ack.setFirstMessageId((MessageId) dispatchedMessage.get(id)); + ack.setFirstMessageId(msgid); iter.remove(); count++; + if( id.equals(messageId) ) { - ack.setLastMessageId((MessageId) dispatchedMessage.get(id)); + ack.setLastMessageId(msgid); break; } + } ack.setMessageCount(count);