如何集成rabbit mq客户端库

时间:2014-10-22 10:15:42

标签: ios rabbitmq librabbitmq

关于Rabbit MQ的大量搜索,我找到了librabbitmq-c的目标C包装器,其链接指向librabbitmq-objc

找到https://github.com/alanxz/rabbitmq-c的librabbitmq-c链接。

我尝试将两者都集成到我的应用程序中,产生了很多错误,如

i)  <Cocoa/Cocoa.h> file not found
ii) <amqp.h> file not found
iii)Too few arguements passing to amqp_basic_consume() method in AMQPConsumer.m
iv) Use of undeclared identifier AMQ_PLATFORM in amqp_socket.c file.
v)  Use of undeclared identifier AMQP_EXCHANGE_TYPE_DIRECT in AMQPExchange.m
vi) ""---------""----- ""------- AMQP_EXCHANGE_TYPE_FANOUT in ""---""-------
vii)--""-----------""----------- AMQP_EXCHANGE_TYPE_TOPIC in ""----""-------

我还从此链接https://github.com/alanxz/rabbitmq-c/releases/download/v0.5.2/rabbitmq-c-0.5.2.tar.gz

尝试了最新版本的librabbitmq-c

<Cocoa/Cocoa.h>替换<Foundation/Foundation.h>解决了第一个和第二个问题 和<amqp.h>"amqp.h"

但我无法解决剩下的问题

我的客户端库实现如下: -

NSString *workQueueName = @"MyQueue";

AMQPExchange *exchange;
AMQPConnection *connection = [[AMQPConnection alloc] init];

[connection connectToHost:@"localhost" onPort:5672];
[connection loginAsUser:@"guest" withPasswort:@"guest" onVHost:@"/"];

AMQPChannel *receiverChannel = [connection openChannel];

AMQPQueue *queue = [[AMQPQueue alloc] initWithName:workQueueName
                                          onChannel:receiverChannel
                                          isPassive:NO
                                        isExclusive:NO
                                          isDurable:NO 
                                    getsAutoDeleted:YES];

exchange = [[AMQPExchange alloc] initFanoutExchangeWithName:@"EXCHANGE_NAME" onChannel:receiverChannel isPassive:NO isDurable:NO getsAutoDeleted:NO];

[queue bindToExchange:exchange withKey:workQueueName];


AMQPConsumer *consumer = [[AMQPConsumer alloc] initForQueue:queue onChannel:receiverChannel useAcknowledgements:NO isExclusive:NO receiveLocalMessages:YES];

AMQPConsumerThread *wqThread = [[AMQPConsumerThread alloc] initWithConsumer:consumer];
wqThread.delegate = self;

[wqThread start];

有关Rabbit MQ的任何帮助将不胜感激,谢谢

1 个答案:

答案 0 :(得分:1)

经过很长一段时间我才解决了。

请参阅此链接以获取图书馆

https://dl.dropboxusercontent.com/u/75870052/AMQPLib.zip

并参考以下链接了解详情...

https://stackoverflow.com/a/26601155/1305001