How to integrate rabbit mq client library

1k Views Asked by At

On lots of searching about Rabbit MQ I found objective C wrapper for librabbitmq-c whose link is directed to librabbitmq-objc.

For librabbitmq-c link found https://github.com/alanxz/rabbitmq-c.

I tried to integrate both in my application by lots of error are produced like

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 ""----""-------

I also tried latest version of librabbitmq-c from this link https://github.com/alanxz/rabbitmq-c/releases/download/v0.5.2/rabbitmq-c-0.5.2.tar.gz

First and second issue solved by replacing <Cocoa/Cocoa.h> with <Foundation/Foundation.h> and <amqp.h> with "amqp.h"

But I am not able to solve rest of them

My client library implementation is given below:-

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];

Any help regarding Rabbit MQ will be appreciated, thanks

1

There are 1 best solutions below

1
On BEST ANSWER

After long period of time I have solved it.

Please refer this link for library

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

and refer following link for detail...

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