use of org.apache.qpid.amqp_1_0.type.Section 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.Section 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.Section 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.Section in project storm by apache.
the class EventHubReceiverImpl method createMessageId.
private MessageId createMessageId(Message message) {
String offset = null;
long sequenceNumber = 0;
for (Section section : message.getPayload()) {
if (section instanceof MessageAnnotations) {
MessageAnnotations annotations = (MessageAnnotations) section;
HashMap annonationMap = (HashMap) annotations.getValue();
if (annonationMap.containsKey(OffsetKey)) {
offset = (String) annonationMap.get(OffsetKey);
}
if (annonationMap.containsKey(SequenceNumberKey)) {
sequenceNumber = (Long) annonationMap.get(SequenceNumberKey);
}
}
}
return MessageId.create(partitionId, offset, sequenceNumber);
}
use of org.apache.qpid.amqp_1_0.type.Section in project storm by apache.
the class EventHubReceiverMock method receive.
@Override
public EventData receive(long timeoutInMilliseconds) {
if (isPaused) {
return null;
}
currentOffset++;
List<Section> body = new ArrayList<Section>();
//the body of the message is "message" + currentOffset, e.g. "message123"
body.add(new Data(new Binary(("message" + currentOffset).getBytes())));
Message m = new Message(body);
MessageId mid = new MessageId(partitionId, "" + currentOffset, currentOffset);
EventData ed = new EventData(m, mid);
return ed;
}
Aggregations