Example usage for com.rabbitmq.client.impl MethodArgumentWriter flush

List of usage examples for com.rabbitmq.client.impl MethodArgumentWriter flush

Introduction

In this page you can find the example usage for com.rabbitmq.client.impl MethodArgumentWriter flush.

Prototype

public void flush() throws IOException 

Source Link

Document

Public API - call this to ensure all accumulated argument values are correctly written to the output stream.

Usage

From source file:uk.trainwatch.rabbitmq.RabbitMQ.java

License:Apache License

/**
 * Convert a map to an AMQP table// w w w  .  j  a  v  a  2 s  . c o m
 *
 * @param args
 *
 * @return
 */
public static byte[] toAMQPTable(Map<String, Object> args) {
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        MethodArgumentWriter writer = new MethodArgumentWriter(new ValueWriter(new DataOutputStream(buffer)));

        writer.writeTable(fixAMQPTable(args));
        writer.flush();
        return buffer.toByteArray();
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
}