0

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

对于 librabbitmq-c 链接找到https://github.com/alanxz/rabbitmq-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 ""----""-------

我还通过此链接尝试了最新版本的 librabbitmq-c https://github.com/alanxz/rabbitmq-c/releases/download/v0.5.2/rabbitmq-c-0.5.2.tar.gz

第一个和第二个问题通过用<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的帮助将不胜感激,谢谢

4

1 回答 1

1

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

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

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

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

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

于 2014-10-28T05:08:24.460 回答