use of org.apache.qpid.amqp_1_0.client.Message 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.client.Message 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.client.Message 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.client.Message in project storm by apache.
the class EventHubReceiverImpl method receive.
@Override
public EventData receive(long timeoutInMilliseconds) {
long start = System.currentTimeMillis();
Message message = receiver.receive(timeoutInMilliseconds);
long end = System.currentTimeMillis();
long millis = (end - start);
receiveApiLatencyMean.update(millis);
receiveApiCallCount.incr();
if (message == null) {
/*if(timeoutInMilliseconds > 100 && millis < timeoutInMilliseconds/2) {
throw new RuntimeException(
"Restart EventHubSpout due to failure of receiving messages in "
+ millis + " millisecond");
}*/
return null;
}
receiveMessageCount.incr();
MessageId messageId = createMessageId(message);
return EventData.create(message, messageId);
}
use of org.apache.qpid.amqp_1_0.client.Message 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);
}
Aggregations