Examples of AsciiBuffer


Examples of org.fusesource.hawtbuf.AsciiBuffer

        String DATA = "abcdefghijklmnopqrstuvwxyz";
        String body = "";
        for( int i=0; i < size; i ++) {
            body += DATA.charAt(i%DATA.length());
        }
       Buffer msg = new AsciiBuffer(body);

        MQTT mqtt = new MQTT();
        mqtt.setHost(host, port);
        mqtt.setUserName(user);
        mqtt.setPassword(password);

        FutureConnection connection = mqtt.futureConnection();
        connection.connect().await();

        final LinkedList<Future<Void>> queue = new LinkedList<Future<Void>>();
        UTF8Buffer topic = new UTF8Buffer(destination);
        for( int i=1; i <= messages; i ++) {

            // Send the publish without waiting for it to complete. This allows us
            // to send multiple message without blocking..
            queue.add(connection.publish(topic, msg, QoS.AT_LEAST_ONCE, false));

            // Eventually we start waiting for old publish futures to complete
            // so that we don't create a large in memory buffer of outgoing message.s
            if( queue.size() >= 1000 ) {
                queue.removeFirst().await();
            }

            if( i % 1000 == 0 ) {
                System.out.println(String.format("Sent %d messages.", i));
            }
        }

        queue.add(connection.publish(topic, new AsciiBuffer("SHUTDOWN"), QoS.AT_LEAST_ONCE, false));
        while( !queue.isEmpty() ) {
            queue.removeFirst().await();
        }

        connection.disconnect().await();
View Full Code Here

Examples of org.fusesource.hawtbuf.AsciiBuffer

                final Task publish = this;
                Buffer message  = body;
                if(prefixCounter) {
                    long id = sent + 1;
                    ByteArrayOutputStream os = new ByteArrayOutputStream(message.length + 15);
                    os.write(new AsciiBuffer(Long.toString(id)));
                    os.write(':');
                    os.write(body);
                    message = os.toBuffer();
                }
                connection.publish(topic, message, qos, retain, new Callback<Void>() {
View Full Code Here

Examples of org.fusesource.hawtbuf.AsciiBuffer

    ExportStreamManager(OutputStream target, int version) throws IOException {
        this.target = target;
        this.version = version;
        stream = new TarOutputStream(new GZIPOutputStream(target));
        store("ver", new AsciiBuffer(""+version));
    }
View Full Code Here

Examples of org.fusesource.hawtbuf.AsciiBuffer

public class AsciiBufferCodec extends AbstractBufferCodec<AsciiBuffer> {
    public static final AsciiBufferCodec INSTANCE = new AsciiBufferCodec();

    @Override
    protected AsciiBuffer createBuffer(byte[] data) {
        return new AsciiBuffer(data);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.