[rabbitmq-discuss] Deleting queues doesn't cut connection?

Haster haster2004 at yandex.ru
Fri Aug 16 14:09:03 BST 2013


Vichael, thanks for reply.
I subscribe for server-pushed deliveries using basic.consume method.
Loop of reading is something like belowЖ
  int wait(int fd, int timeout_msec)
  {
    fd_set fds;
    fd_set errfd;
    struct timeval tv;

    FD_ZERO(&fds);
    FD_SET(fd, &fds);

    FD_ZERO(&errfd);
    FD_SET(fd, &errfd);

    tv.tv_sec  = timeout_msec / 1000;
    tv.tv_usec = 1000 * (timeout_msec % 1000); //mksec

    int rc = select(fd + 1, &fds, NULL, &errfd, &tv);

    if(rc == -1)
      return SELECT_ERROR;
    else if(rc == 0)
      return TIMEOUT;
    if(FD_ISSET(fd, &errfd))
      return FDSET_ERROR;
    return READY;
  }

  RabbitMQMessage *RabbitMQQueueImpl::recv(int timeout)
throw(RabbitMQException) {
    amqp_connection_state_t conn = connection.getConnection();
    std::string temp;
    std::auto_ptr<RabbitMQMessageImpl> message(new RabbitMQMessageImpl(conn,
autoAck ? NULL : channel, 0, 0, 0));

    while (true) {
      amqp_maybe_release_buffers(conn);
      
      if (!amqp_data_in_buffer(conn) && !amqp_frames_enqueued(conn)) {
        *switch (wait(connection.getfd(), timeout)) {*
          case READY:
            break;
          case SELECT_ERROR:
          case FDSET_ERROR:
            throw RabbitMQException(-1, "Connection error");
          case TIMEOUT:
            return NULL;
          default:
            throw RabbitMQException(-1, "Unexpected");
        }
      }

      amqp_maybe_release_buffers(conn);

      amqp_frame_t frame;
      int result = amqp_simple_wait_frame(conn, &frame);

      if (result < 0) {
        return NULL;
      }
...



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/Deleting-queues-doesn-t-cut-connection-tp28872p28877.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list