Package com.swiftmq.amqp.v100.generated.messaging.message_format

Examples of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties


                Session session = connection.createSession(10, 10);
                Producer p = session.createProducer(queue, qos);
                for (int i = 0; i < nMsgs; i++) {
                    AMQPMessage msg = new AMQPMessage();
                    System.out.println("Sending " + i);
                    msg.setAmqpValue(new AmqpValue(new AMQPString(String.format(dataFormat, i))));
                    p.send(msg);
                }
                p.close();
                session.close();
            }
View Full Code Here


        Consumer c = s.createConsumer(consumerSource, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        Producer p = s.createProducer(producerTarget, QoS.AT_LEAST_ONCE);
        AMQPMessage msg = msg();
        AmqpValue sentinel = new AmqpValue(new AMQPDouble(Math.random()));
        msg.setAmqpValue(sentinel);
        Properties props = new Properties();
        props.setSubject(new AMQPString(routingKey));
        msg.setProperties(props);
        p.send(msg);

        if (succeed) {
            AMQPMessage m = c.receive();
View Full Code Here

            {

                Session session = connection.createSession(10, 10);
                Producer p = session.createProducer(queue, qos);
                for (int i = 0; i < nMsgs; i++) {
                    AMQPMessage msg = new AMQPMessage();
                    System.out.println("Sending " + i);
                    msg.setAmqpValue(new AmqpValue(new AMQPString(String.format(dataFormat, i))));
                    p.send(msg);
                }
                p.close();
                session.close();
            }
            System.out.println("=======================================================================================");
            System.out.println(" receiving ");
            System.out.println("=======================================================================================");
            {
                Session session = connection.createSession(10, 10);
                Consumer c = session.createConsumer(queue, 100, qos, true, null);

                // Receive messages non-transacted
                int i = 0;
                while ( i < nMsgs) {
                    AMQPMessage msg = c.receive();
                    if( msg!=null ) {
                        final AMQPType value = msg.getAmqpValue().getValue();
                        if (value instanceof AMQPString) {
                            String s = ((AMQPString) value).getValue();
                            assertEquals(String.format(dataFormat, i), s);
                            System.out.println("Received: " + i);
                        }
                        if (!msg.isSettled())
                            msg.accept();
                        i++;
                    }
                }
                c.close();
                session.close();
View Full Code Here

    private static final int OUTBOUND_WINDOW = 100;
    private static final int CONSUMER_LINK_CREDIT = 200;
    private static final String QUEUE = "/queue/test";

    private AMQPMessage msg() {
        AMQPMessage m = new AMQPMessage();
        m.addData(data());
        return m;
    }
View Full Code Here

        Session s = conn.createSession(INBOUND_WINDOW, OUTBOUND_WINDOW);
        Producer p = s.createProducer(QUEUE, QoS.AT_LEAST_ONCE);
        p.send(msg());
        p.close(); // Settlement happens here
        Consumer c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        AMQPMessage m = c.receive();
        m.accept();
        assertEquals(1, m.getData().size());
        assertEquals(data(), m.getData().get(0));
        conn.close();
    }
View Full Code Here

        conn.setMaxFrameSize(FrameSize);
        conn.connect();
        Session s = conn.createSession(INBOUND_WINDOW, OUTBOUND_WINDOW);

        Producer p = s.createProducer(QUEUE, QoS.AT_LEAST_ONCE);
        AMQPMessage msg = new AMQPMessage();
        msg.addData(new Data(new byte [PayloadSize]));
        p.send(msg);
        p.close();

        Consumer c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        AMQPMessage m = c.receive();
        m.accept();
        c.close();
        assertEquals(PayloadSize, m.getData().get(0).getValue().length);
        conn.close();
    }
View Full Code Here

        Connection conn = new Connection(ctx, host, port, false);
        conn.connect();

        Session s = conn.createSession(INBOUND_WINDOW, OUTBOUND_WINDOW);
        Producer p = s.createProducer(QUEUE, QoS.AT_LEAST_ONCE);
        AMQPMessage msg = new AMQPMessage();

        List<AMQPType> al = new ArrayList<AMQPType>();
        al.add(new AMQPBoolean(true));
        al.add(new AMQPByte(Byte.MAX_VALUE));
        al.add(new AMQPChar(Character.CURRENCY_SYMBOL));
        al.add(new AMQPDecimal64(BigDecimal.TEN));
        al.add(new AMQPDouble(Double.NaN));
        al.add(new AMQPInt(Integer.MIN_VALUE));
        al.add(new AMQPNull());
        al.add(new AMQPString("\uFFF9"));
        al.add(new AMQPSymbol(new String(new char[256])));
        al.add(new AMQPTimestamp(Long.MAX_VALUE));
        al.add(new AMQPUuid(System.currentTimeMillis(), Long.MIN_VALUE));
        al.add(new AMQPUnsignedShort(0));
        al.add(new AMQPArray(AMQPBoolean.FALSE.getCode(), new AMQPBoolean[]{}));
        al.add(new AmqpSequence(new ArrayList<AMQPType>()));
        AmqpSequence seq = new AmqpSequence(al);
        AmqpValue val = new AmqpValue(seq);
        msg.setAmqpValue(val);

        p.send(msg);
        p.close();
        Consumer c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        AMQPMessage recvMsg = c.receive();
        recvMsg.accept();

        assertEquals(val.getValue().getValueString(), recvMsg.getAmqpValue().getValue().getValueString());
        conn.close();
    }
View Full Code Here

        Producer p = s.createProducer(QUEUE, QoS.AT_MOST_ONCE);
        p.send(msg());
        p.close();

        Consumer c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_MOST_ONCE, false, null);
        AMQPMessage m = c.receive();
        assertTrue(m.isSettled());

        s.close();
        s = conn.createSession(INBOUND_WINDOW, OUTBOUND_WINDOW);
        c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_MOST_ONCE, false, null);
        assertNull(get(c));
View Full Code Here

        Producer p = s.createProducer(QUEUE, QoS.AT_LEAST_ONCE);
        p.send(msg());
        p.close();

        Consumer c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        AMQPMessage m = c.receive();
        m.reject();
        assertNull(get(c));
        conn.close();
    }
View Full Code Here

        Producer p = s.createProducer(QUEUE, QoS.AT_MOST_ONCE);
        p.send(msg());
        p.close();

        Consumer c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        AMQPMessage m1 = c.receive();
        assertTrue(m1.getHeader().getFirstAcquirer().getValue());
        assertFalse(m1.isSettled());

        s.close();
        s = conn.createSession(INBOUND_WINDOW, OUTBOUND_WINDOW);
        c = s.createConsumer(QUEUE, CONSUMER_LINK_CREDIT, QoS.AT_LEAST_ONCE, false, null);
        AMQPMessage m2 = c.receive();
        m2.accept();

        assertTrue(compareMessageData(m1, m2));
        assertFalse(m2.getHeader().getFirstAcquirer().getValue());
        assertNull(get(c));
        conn.close();
    }
View Full Code Here

TOP

Related Classes of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.