Author: jicken
Date: 2011-05-31 17:39:47 -0400 (Tue, 31 May 2011)
New Revision: 10755
Modified:
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
Log:
Bugfix message payload exporting/importing
Modified:
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java
===================================================================
---
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-31
19:37:23 UTC (rev 10754)
+++
branches/Branch_2_2_EAP_export_tool/src/main/org/hornetq/core/persistence/tools/ManageDataTool.java 2011-05-31
21:39:47 UTC (rev 10755)
@@ -37,6 +37,7 @@
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.Message;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientProducer;
@@ -347,13 +348,13 @@
private static void handleAddMessage(MessagesExportType journalType, RecordInfo info)
{
- JournalStorageManager.MessageDescribe message =
(JournalStorageManager.MessageDescribe)JournalStorageManager.newObjectEncoding(info);
+ final Message msg =
((MessageDescribe)JournalStorageManager.newObjectEncoding(info)).msg;
+ MessageType messageType = new MessageType((ServerMessage) msg);
- MessageType messageType = new MessageType((ServerMessage)message.msg);
+ final HornetQBuffer bodyBuffer = msg.getBodyBuffer();
+ byte[] data = bodyBuffer.toByteBuffer().array();
+ messageType.setPayload(Base64.encodeBytes(data, MessageImpl.BODY_OFFSET,
((ServerMessage) msg).getEndOfBodyPosition() - MessageImpl.BODY_OFFSET,
Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
- byte[] data = info.data;
- messageType.setPayload(Base64.encodeBytes(data, 0, data.length,
Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
-
journalType.getMessage().add(messageType);
}
@@ -520,7 +521,6 @@
queueQuery =
coreSession.queueQuery(SimpleString.toSimpleString(queue.getName()));
}
- // todo: get new queue id
if (!queueMapping.containsKey(queue.getId())) {
long newQueueId = getNewQueueId(queue);
queueMapping.put(queue.getId(), newQueueId);
@@ -586,8 +586,7 @@
}
// Payload
- HornetQBuffer buffer = clientMessage.getBodyBuffer();
- buffer.writeBytes(Base64.decode(message.getPayload(),
Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
+
clientMessage.getBodyBuffer().writeBytes(Base64.decode(message.getPayload(),
Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
// UserID
// todo: need to set?
Modified:
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java
===================================================================
---
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-31
19:37:23 UTC (rev 10754)
+++
branches/Branch_2_2_EAP_export_tool/tests/src/org/hornetq/tests/integration/persistence/ExportDataTest.java 2011-05-31
21:39:47 UTC (rev 10755)
@@ -117,6 +117,9 @@
{
ClientMessage msg = cons.receive(1000);
assertNotNull(msg);
+ for (int b = 0; b < msg.getBodyBuffer().readableBytes(); b++) {
+ assertEquals(getSamplebyte(b), msg.getBodyBuffer().readByte());
+ }
msg.acknowledge();
assertEquals(i, msg.getIntProperty("count").intValue());
}
Show replies by date