Search in sources :

Example 1 with AMQPLong

use of com.swiftmq.amqp.v100.types.AMQPLong in project swiftmq-ce by iitsoftware.

the class AMQPValueMapMessageFactory method verify.

public void verify(AMQPMessage message) throws Exception {
    AmqpValue value = message.getAmqpValue();
    if (value == null)
        throw new Exception(("verify - no AmqpValue section found!"));
    AMQPType t = value.getValue();
    if (!(t instanceof AMQPMap))
        throw new Exception(("verify - AmqpValue does not contain an AmqpMap!"));
    Map map = ((AMQPMap) message.getAmqpValue().getValue()).getValue();
    for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry entry = (Map.Entry) iter.next();
        if (!((entry.getKey() instanceof AMQPString && ((AMQPString) entry.getKey()).getValue().equals("key1")) || (entry.getKey() instanceof AMQPString && ((AMQPString) entry.getKey()).getValue().equals("key3")) || (entry.getKey() instanceof AMQPString && ((AMQPString) entry.getKey()).getValue().equals("REPLY")) || (entry.getKey() instanceof AMQPString && ((AMQPString) entry.getKey()).getValue().equals(String.valueOf(Integer.MAX_VALUE + 1))) || (entry.getKey() instanceof AMQPString && ((AMQPString) entry.getKey()).getValue().equals(String.valueOf(Integer.MAX_VALUE + 2))) || (entry.getKey() instanceof AMQPLong && ((AMQPLong) entry.getKey()).getValue() == Integer.MAX_VALUE + 1) || (entry.getKey() instanceof AMQPLong && ((AMQPLong) entry.getKey()).getValue() == Integer.MAX_VALUE + 2))) {
            System.out.println(map);
            throw new Exception("verify - invalid values in map detected: " + map);
        }
    }
}
Also used : AMQPType(com.swiftmq.amqp.v100.types.AMQPType) AMQPMap(com.swiftmq.amqp.v100.types.AMQPMap) AMQPLong(com.swiftmq.amqp.v100.types.AMQPLong) Iterator(java.util.Iterator) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) AMQPMap(com.swiftmq.amqp.v100.types.AMQPMap) Map(java.util.Map) HashMap(java.util.HashMap) AmqpValue(com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)

Example 2 with AMQPLong

use of com.swiftmq.amqp.v100.types.AMQPLong in project swiftmq-ce by iitsoftware.

the class AMQPValueMapMessageFactory method create.

public AMQPMessage create(int sequenceNo) throws Exception {
    AMQPMessage msg = new AMQPMessage();
    Map map = new HashMap();
    map.put(new AMQPString("key1"), new AMQPString("value1"));
    map.put(new AMQPLong(Integer.MAX_VALUE + 1), new AMQPLong(200));
    map.put(new AMQPString("key3"), new AMQPString("value1"));
    map.put(new AMQPLong(Integer.MAX_VALUE + 2), new AMQPLong(400));
    msg.setAmqpValue(new AmqpValue(new AMQPMap(map)));
    return msg;
}
Also used : AMQPMap(com.swiftmq.amqp.v100.types.AMQPMap) HashMap(java.util.HashMap) AMQPLong(com.swiftmq.amqp.v100.types.AMQPLong) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) AMQPMap(com.swiftmq.amqp.v100.types.AMQPMap) Map(java.util.Map) HashMap(java.util.HashMap) AmqpValue(com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)

Example 3 with AMQPLong

use of com.swiftmq.amqp.v100.types.AMQPLong in project swiftmq-ce by iitsoftware.

the class AMQPSequenceMessageFactory method create.

public AMQPMessage create(int sequenceNo) throws Exception {
    AMQPMessage msg = new AMQPMessage();
    List list = new ArrayList();
    list.add(new AMQPString("key1"));
    list.add(new AMQPLong(Integer.MAX_VALUE + 1));
    list.add(new AMQPString("key3"));
    list.add(new AMQPLong(Integer.MAX_VALUE + 2));
    msg.addAmqpSequence(new AmqpSequence(list));
    return msg;
}
Also used : AMQPLong(com.swiftmq.amqp.v100.types.AMQPLong) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) AmqpSequence(com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpSequence)

Aggregations

AMQPLong (com.swiftmq.amqp.v100.types.AMQPLong)3 AMQPString (com.swiftmq.amqp.v100.types.AMQPString)3 AmqpValue (com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)2 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)2 AMQPMap (com.swiftmq.amqp.v100.types.AMQPMap)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AmqpSequence (com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpSequence)1 AMQPType (com.swiftmq.amqp.v100.types.AMQPType)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1