Ejemplo n.º 1
0
  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));
            }
          });
    }
  }
Ejemplo n.º 2
0
 @Override
 public void close() throws IOException {
   channel.close();
   connection.close();
 }