Ejemplo n.º 1
0
 @Override
 protected AMQPQueueConsumer getConsumer(
     Object callback, AMQPCommonListenProperties commonListenProperties, String poisonPrefix) {
   return new AMQPQueueConsumer(
       getChannel(),
       (AMQPConsumerCallback) callback,
       commonListenProperties.getThreshold(),
       poisonPrefix,
       commonListenProperties.isPoisonQueueEnabled());
 }
Ejemplo n.º 2
0
  @Override
  protected void listenImpl(TransportListenProperties properties) throws IOException {
    final boolean noAutoAck = false;
    AMQPCommonListenProperties commonListenProperties = getCommonListenProperties(properties);
    String queue = commonListenProperties.getQueue();
    String poisonPrefix = commonListenProperties.getPoisonPrefix();

    if (commonListenProperties.isDynamicQueueCreation()) {
      queue =
          createDynamicQueue(
              commonListenProperties.getExchange(),
              commonListenProperties.getDynamicQueueRoutingKey(),
              commonListenProperties.isPoisonQueueEnabled());
      poisonPrefix = "." + queue;
    } else if (commonListenProperties.isAutoCreateAndBind()) {
      autoCreateAndBind(
          commonListenProperties.getExchange(),
          commonListenProperties.getExchangeType(),
          commonListenProperties.getQueue(),
          commonListenProperties.getRoutingKey(),
          commonListenProperties.isPoisonQueueEnabled());
    }

    if (commonListenProperties.shouldPurgeOnConnect()) {
      channel.queuePurge(queue);
    }

    AMQPQueueConsumer consumer =
        getConsumer(getConsumerCallback(properties), commonListenProperties, poisonPrefix);
    getChannel().basicQos(commonListenProperties.getPrefetchCount());
    getChannel().basicConsume(queue, noAutoAck, consumer);
  }