use of org.apache.qpid.amqp_1_0.client.Message in project storm by apache.
the class EventHubSpout method nextTuple.
@Override
public void nextTuple() {
EventData eventData = null;
List<IPartitionManager> partitionManagers = partitionCoordinator.getMyPartitionManagers();
for (int i = 0; i < partitionManagers.size(); i++) {
currentPartitionIndex = (currentPartitionIndex + 1) % partitionManagers.size();
IPartitionManager partitionManager = partitionManagers.get(currentPartitionIndex);
if (partitionManager == null) {
throw new RuntimeException("partitionManager doesn't exist.");
}
eventData = partitionManager.receive();
if (eventData != null) {
break;
}
}
if (eventData != null) {
MessageId messageId = eventData.getMessageId();
Message message = eventData.getMessage();
List<Object> tuples = scheme.deserialize(message);
if (tuples != null) {
collector.emit(tuples, messageId);
}
}
checkpointIfNeeded();
// We don't need to sleep here because the IPartitionManager.receive() is
// a blocked call so it's fine to call this function in a tight loop.
}
use of org.apache.qpid.amqp_1_0.client.Message 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