Search in sources :

Example 6 with Message

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.
}
Also used : Message(org.apache.qpid.amqp_1_0.client.Message)

Example 7 with Message

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;
}
Also used : Message(org.apache.qpid.amqp_1_0.client.Message) ArrayList(java.util.ArrayList) Data(org.apache.qpid.amqp_1_0.type.messaging.Data) EventData(org.apache.storm.eventhubs.spout.EventData) Binary(org.apache.qpid.amqp_1_0.type.Binary) Section(org.apache.qpid.amqp_1_0.type.Section) EventData(org.apache.storm.eventhubs.spout.EventData) MessageId(org.apache.storm.eventhubs.spout.MessageId)

Aggregations

Section (org.apache.qpid.amqp_1_0.type.Section)5 ArrayList (java.util.ArrayList)4 Data (org.apache.qpid.amqp_1_0.type.messaging.Data)4 HashMap (java.util.HashMap)3 Message (org.apache.qpid.amqp_1_0.client.Message)3 Map (java.util.Map)2 AmqpValue (org.apache.qpid.amqp_1_0.type.messaging.AmqpValue)2 ApplicationProperties (org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties)2 Binary (org.apache.qpid.amqp_1_0.type.Binary)1 MessageAnnotations (org.apache.qpid.amqp_1_0.type.messaging.MessageAnnotations)1 EventData (org.apache.storm.eventhubs.spout.EventData)1 MessageId (org.apache.storm.eventhubs.spout.MessageId)1