Ejemplo n.º 1
0
  @Override
  public boolean endSubscribtionToChannel(String exchangeName) {
    Channel channel = subscribedChannels.get(exchangeName);
    if (channel != null) {
      try {
        String queueName = channel.queueDeclare().getQueue();
        channel.queueUnbind(queueName, exchangeName, "");
        //				channel.basicConsume(queueName, arg1)

        //				channel.close(0,exchangeName);
        subscribedChannels.remove(exchangeName);
        channel = null;
        Log.i(
            LOGTAG,
            "subscribed to "
                + subscribedChannels.size()
                + " Channels"
                + "\n"
                + "ended subscribtion to : "
                + exchangeName);
        return true;
      } catch (AlreadyClosedException e) {
        Log.e(LOGTAG, "endSubcribtionToChannel: " + e.toString());
        subscribedChannels.remove(exchangeName);
      } catch (IOException e) {
        Log.e(LOGTAG, "endSubcribtionToChannel: " + e.toString());
      } catch (ShutdownSignalException e) {
        Log.e(LOGTAG, "endSubcribtionToChannel: " + e.toString());
      }
    }
    return false;
  }
Ejemplo n.º 2
0
 public void testDeclarationOfManyAutoDeleteExchangesWithTransientQueuesThatAreUnbound()
     throws IOException, TimeoutException {
   Channel ch = connection.createChannel();
   assertRecordedExchanges(connection, 0);
   for (int i = 0; i < 5000; i++) {
     String x = UUID.randomUUID().toString();
     ch.exchangeDeclare(x, "fanout", false, true, null);
     String q = ch.queueDeclare().getQueue();
     final String rk = "doesn't matter";
     ch.queueBind(q, x, rk);
     ch.queueUnbind(q, x, rk);
     ch.queueDelete(q);
   }
   assertRecordedExchanges(connection, 0);
   ch.close();
 }