I rate RabbitMQ, and although the overall impression (AMQP as such as well as RabbitMQ) is positive, I am not very impressed with the result.
I try to publish and consume messages at the same time and get very bad messages. I have a reliable direct exchange, which is associated with a reliable queue, and I publish constant messages for this exchange. The average message body size is about 1000 bytes.
My posting goes something like this:
AMQP.BasicProperties.Builder bldr = new AMQP.BasicProperties.Builder();
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("guest");
factory.setPassword("guest");
factory.setVirtualHost("/");
factory.setHost("my-host");
factory.setPort(5672);
Connection conn = null;
Channel channel = null;
ObjectMapper mapper = new ObjectMapper();
try {
conn = factory.newConnection();
channel = conn.createChannel();
channel.confirmSelect();
} catch (IOException e) {}
for(Message m : messageList) {
try {
channel.basicPublish("exchange", "", bldr.deliveryMode(2).contentType("application/json").build(), mapper.writeValueAsBytes(cm));
} catch (Exception e) {}
}
try {
channel.waitForConfirms();
channel.close();
conn.close();
} catch (Exception e1) {}
And consuming messages from the linked queue happen like this:
AMQP.BasicProperties.Builder bldr = new AMQP.BasicProperties.Builder();
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("guest");
factory.setPassword("guest");
factory.setVirtualHost("/");
factory.setHost("my-host");
factory.setPort(5672);
Connection conn = null;
Channel channel = null;
try {
conn = factory.newConnection();
channel = conn.createChannel();
channel.basicQos(100);
while (true) {
GetResponse r = channel.basicGet("rawDataQueue", false);
if(r!=null)
channel.basicAck(r.getEnvelope().getDeliveryTag(), false);
}
} catch (IOException e) {}
, , ( ) ( ) , (), , , - RabbitMQ , , ~ 2... 3 . , 0,5... 3 . , , , 300... 600 . QOS Java-, 100 250 , .
, , ~ 400 ~ 50 , , .
, RabbitMQ, , , , , , , - .
QOS , IMHO .
, -, (2 )? - - , ? , , . , - , - :)