use of org.apache.qpid.amqp_1_0.type.messaging.AmqpValue 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.AmqpValue 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.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithContentType.
public void testAmqpValueWithNullWithContentType() throws Exception {
Properties properties = new Properties();
final String mimeType = "foo/bar";
properties.setContentType(Symbol.valueOf(mimeType));
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(properties, amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", mimeType, convertedMessage.getMessageHeader().getMimeType());
assertNull("Unexpected content", convertedMessage.getMessageBody());
}
use of org.apache.qpid.amqp_1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithUnknownMessageAnnotation.
public void testAmqpValueWithNullWithUnknownMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(new MessageAnnotations(Collections.singletonMap(Symbol.valueOf("x-opt-jms-msg-type"), (byte) 11)), amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
assertNull("Unexpected content", convertedMessage.getMessageBody());
}
use of org.apache.qpid.amqp_1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithBytesMessageAnnotation.
public void testAmqpValueWithNullWithBytesMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(BYTE_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
assertNull("Unexpected content", convertedMessage.getMessageBody());
}
Aggregations