use of org.apache.qpid.amqp_1_0.type.messaging.Data in project storm by apache.
the class StringEventDataScheme method deserialize.
@Override
public List<Object> deserialize(Message message) {
final List<Object> fieldContents = new ArrayList<Object>();
for (Section section : message.getPayload()) {
if (section instanceof Data) {
Data data = (Data) section;
fieldContents.add(new String(data.getValue().getArray()));
} else if (section instanceof AmqpValue) {
AmqpValue amqpValue = (AmqpValue) section;
fieldContents.add(amqpValue.getValue().toString());
}
}
return fieldContents;
}
use of org.apache.qpid.amqp_1_0.type.messaging.Data in project storm by apache.
the class BinaryEventDataScheme method deserialize.
@Override
public List<Object> deserialize(Message message) {
final List<Object> fieldContents = new ArrayList<Object>();
Map metaDataMap = new HashMap();
byte[] messageData = new byte[0];
for (Section section : message.getPayload()) {
if (section instanceof Data) {
Data data = (Data) section;
messageData = data.getValue().getArray();
} else if (section instanceof ApplicationProperties) {
final ApplicationProperties applicationProperties = (ApplicationProperties) section;
metaDataMap = applicationProperties.getValue();
}
}
fieldContents.add(messageData);
fieldContents.add(metaDataMap);
return fieldContents;
}
use of org.apache.qpid.amqp_1_0.type.messaging.Data in project storm by apache.
the class EventDataScheme method deserialize.
@Override
public List<Object> deserialize(Message message) {
final List<Object> fieldContents = new ArrayList<Object>();
Map metaDataMap = new HashMap();
String messageData = "";
for (Section section : message.getPayload()) {
if (section instanceof Data) {
Data data = (Data) section;
messageData = new String(data.getValue().getArray());
} else if (section instanceof AmqpValue) {
AmqpValue amqpValue = (AmqpValue) section;
messageData = amqpValue.getValue().toString();
} else if (section instanceof ApplicationProperties) {
final ApplicationProperties applicationProperties = (ApplicationProperties) section;
metaDataMap = applicationProperties.getValue();
}
}
fieldContents.add(messageData);
fieldContents.add(metaDataMap);
return fieldContents;
}
use of org.apache.qpid.amqp_1_0.type.messaging.Data in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testDataWithStreamMessageAnnotationAndContentTypeJmsStreamMessage.
@Test
public void testDataWithStreamMessageAnnotationAndContentTypeJmsStreamMessage() throws Exception {
List<Object> originalList = Collections.singletonList("testValue");
byte[] data = new ListToJmsStreamMessage().toMimeContent(originalList);
String expectedMimeType = "jms/stream-message";
final Data value = new Data(new Binary(data));
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(expectedMimeType));
Message_1_0 sourceMessage = createTestMessage(properties, STREAM_MESSAGE_MESSAGE_ANNOTATION, value.createEncodingRetainingSection());
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertArrayEquals("Unexpected content", data, getBytes(content));
}
use of org.apache.qpid.amqp_1_0.type.messaging.Data in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testData.
@Test
public void testData() throws Exception {
final byte[] expected = getObjectBytes("helloworld".getBytes(UTF_8));
final Data value = new Data(new Binary(expected));
final Message_1_0 sourceMessage = createTestMessage(value.createEncodingRetainingSection());
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertArrayEquals("Unexpected content", expected, getBytes(content));
}
Aggregations