private void declareConsumers() throws IOException { for (final EndPointMethod endPointMethod : endPointMethods) { final RouteSpec routeSpec = endPointMethod.getRouteIn(); Route route = routeSpec.declareOn(channel, this); log.debug("consuming on " + route.getQueue() + " ==> " + endPointMethod); boolean autoAck = false; channel.basicConsume( route.getQueue(), autoAck, endPointMethod.toString(), new DefaultConsumer(channel) { @Override public void handleDelivery( String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { String routingKey = envelope.getRoutingKey(); String contentType = properties.getContentType(); long deliveryTag = envelope.getDeliveryTag(); endPointMethod.call(new Event(Qarrot.this, channel, envelope, properties, body)); } }); } }
@Override public void close() throws IOException { channel.close(); connection.close(); }