/**
* Test stream marshal by appending one message at a time
*
* @throws Exception
*/
@Test
public void testStreamMarshal() throws Exception {
File file = tempFolder.newFile();
try(FileOutputStream fos = new FileOutputStream(file)) {
XMLStreamWriter xmlWriter = XMLOutputFactory.newFactory().createXMLStreamWriter(fos);
ArtemisJournalMarshaller xmlMarshaller = new ArtemisJournalMarshaller(xmlWriter);
xmlMarshaller.appendJournalOpen();
xmlMarshaller.appendBindingsElement();
xmlMarshaller.appendBinding(new AddressBindingType());
xmlMarshaller.appendEndElement();
xmlMarshaller.appendMessagesElement();
//Marshal messages one at a time
for (int i = 0; i < 3; i++) {
MessageType message = new MessageType();
message.setId((long) i);
message.setTimestamp(System.currentTimeMillis());
xmlMarshaller.appendMessage(message);
}
xmlMarshaller.appendEndElement();
xmlMarshaller.appendJournalClose(true);
}
//This can be read as a stream as well but for the purpose of this test
//just read the whole thing in at once
validate(file);
}
ArtemisJournalMarshallerTest.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:activemq-cli-tools
作者:
评论列表
文章目录