我正在开发一个 iOS 应用程序并为 RabbitMQ https://github.com/profmaad/librabbitmq-objc使用 profmaad 的 Objective-c 客户端
这是我用来建立连接并开始监听事件的代码:
-(void)establish{
   AMQPConnection *connection = [[AMQPConnection alloc] init];
   [connection connectToHost:<host> onPort:<port number>];
   [connection loginAsUser:<username> withPasswort:<password> onVHost:<vHost>];
   AMQPChannel *channel = [connection openChannel];
   AMQPQueue *queue = [[AMQPQueue alloc] initWithName:<queue name> onChannel:channel isPassive:NO isExclusive:NO isDurable:NO getsAutoDeleted:NO];
   AMQPConsumer *consumer = [[AMQPConsumer alloc] initForQueue:queue onChannel:channel useAcknowledgements:YES isExclusive:NO receiveLocalMessages:NO];
   AMQPConsumerThread *consumerThread = [[AMQPConsumerThread alloc] initWithConsumer:consumer];
   consumerThread.delegate = self;
}
-(void)amqpConsumerThreadReceivedNewMessage:(AMQPMessage *)theMessage
{
   NSLog(@"message = %@", theMessage);
   NSLog(@"message.body = %@", theMessage.body);
}
问题是,从未调用过 amqpConsumerThreadReceivedNewMessage!