Package org.apache.qpid.proton.messenger.impl

Examples of org.apache.qpid.proton.messenger.impl.MessengerImpl$MessageAvailable


        bodies = Arrays.copyOfRange(args, i, args.length);
    }

    private void run() {
        try {
            Messenger mng = new MessengerImpl();
            mng.start();
            Message msg = new MessageImpl();
            msg.setAddress(address);
            if (subject != null) msg.setSubject(subject);
            for (String body : bodies) {
                msg.setBody(new AmqpValue(body));
                mng.put(msg);
            }
            mng.send();
            mng.stop();
        } catch (Exception e) {
            tracer.log(Level.SEVERE, "proton error", e);
        }
    }
View Full Code Here


        System.out.println(b.toString());
    }

    private void run() {
        try {
            Messenger mng = new MessengerImpl();
            mng.start();
            for (String a : addrs) {
                mng.subscribe(a);
            }
            int ct = 0;
            boolean done = false;
            while (!done) {
                mng.recv();
                while (mng.incoming() > 0) {
                    Message msg = mng.get();
                    ++ct;
                    print(ct, msg);
                    if (maxct > 0 && ct >= maxct) {
                        done = true;
                        break;
                    }
                }
            }
            mng.stop();
        } catch (Exception e) {
            tracer.log(Level.SEVERE, "proton error", e);
        }
    }
View Full Code Here

public class ProtonTests extends TestCase {
    public static final String ADDRESS = "amqp://localhost/amqp-1.0-test";
    // This uses deprecated classes, yes. I took them from the examples provided...

    public void testRoundTrip() throws Exception {
        Messenger mng = new MessengerImpl();
        mng.start();
        Message msg = new MessageImpl();
        msg.setAddress(ADDRESS);
        msg.setSubject("hello");
        msg.setContentType("application/octet-stream");
        msg.setBody(new Data(new Binary("hello world".getBytes())));
        mng.put(msg);
        mng.send();

        mng.subscribe(ADDRESS);
        mng.recv();
        Message msg2 = mng.get();
        assertEquals(msg.getSubject(), msg2.getSubject());
        assertEquals(msg.getContentType(), msg2.getContentType());
        assertEquals(msg.getBody().toString(), msg2.getBody().toString());
        mng.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.messenger.impl.MessengerImpl$MessageAvailable

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.