[rabbitmq-discuss] Publishing binary data using the java client
Christian Strack
strack at Mathematik.Uni-Marburg.de
Sat Jan 12 14:41:23 GMT 2013
Hi there,
for benchmarking purposes i have set up a an astract testing suite to
transfer data using several transport implementations. The transmitted
data are integers converted to byte arrays using ByteBuffer. While the
en- and decoding of these data is successful using UDP sockets, the
decoding fails when being transmitted using rabbitmq and the rabbitmq
java libraries. The results are just random bytes but the array size is
correct. I have tried to set the encoding to different BasicProperties
which had no impact. Is there a flag that needs to be set to prevent
that rabbitmq alters the data? Below are the important snippets of my code.
Greetings and thanks in advance for any comment or answer
Christian
Sender:
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(params[0]);
factory.setUsername(params[1]);
factory.setPassword(params[2]);
connection = factory.newConnection();
channel = connection.createChannel();
channel.exchangeDeclare(exchange, "fanout");
try {
channel.basicPublish(exchange, "", false,
MessageProperties.BASIC, sendData);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Receiver:
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(params[0]);
factory.setUsername(params[1]);
factory.setPassword(params[2]);
connection = factory.newConnection();
channel = connection.createChannel();
channel.exchangeDeclare(exchange, "fanout");
String queue = channel.queueDeclare().getQueue();
channel.queueBind(queue, exchange, "");
consumer = new QueueingConsumer(channel);
channel.basicConsume(queue, true, consumer);
Delivery delivery = consumer.nextDelivery();
if (delivery != null){
data = delivery.getBody();
}
More information about the rabbitmq-discuss
mailing list