Search in sources :

Example 1 with Section

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;
}
Also used : ArrayList(java.util.ArrayList) Data(org.apache.qpid.amqp_1_0.type.messaging.Data) Section(org.apache.qpid.amqp_1_0.type.Section) AmqpValue(org.apache.qpid.amqp_1_0.type.messaging.AmqpValue)

Example 2 with Section

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApplicationProperties(org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties) Data(org.apache.qpid.amqp_1_0.type.messaging.Data) Map(java.util.Map) HashMap(java.util.HashMap) Section(org.apache.qpid.amqp_1_0.type.Section)

Example 3 with Section

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApplicationProperties(org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties) Data(org.apache.qpid.amqp_1_0.type.messaging.Data) Map(java.util.Map) HashMap(java.util.HashMap) Section(org.apache.qpid.amqp_1_0.type.Section) AmqpValue(org.apache.qpid.amqp_1_0.type.messaging.AmqpValue)

Example 4 with Section

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);
}
Also used : HashMap(java.util.HashMap) MessageAnnotations(org.apache.qpid.amqp_1_0.type.messaging.MessageAnnotations) Section(org.apache.qpid.amqp_1_0.type.Section)

Example 5 with Section

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;
}
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 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 Message (org.apache.qpid.amqp_1_0.client.Message)1 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