Rabbitmq client library for iOS

208 views
Skip to first unread message

Rambabu

unread,
Sep 4, 2015, 4:46:25 AM9/4/15
to rabbitmq-users
Hi,

Can i get rabbitmq client library for iOS?

Thanks 

Michael Klishin

unread,
Sep 4, 2015, 5:47:36 AM9/4/15
to rabbitm...@googlegroups.com, Rambabu
On 4 Sep 2015 at 11:46:27, Rambabu (rambabu...@gmail.com) wrote:
> Can i get rabbitmq client library for iOS?

librabbitmq-c is the best AMQP 0-9-1 client option at the moment.

Note that you can use STOMP or MQTT (3.1.1) clients on iOS as well. 
--
MK

Staff Software Engineer, Pivotal/RabbitMQ


Winston

unread,
Mar 31, 2016, 12:29:06 AM3/31/16
to rabbitmq-users
Hi,
You can try this. 

First, the connection.

self.connection = [[AMQPConnection alloc] initWithHost:mqAddress port:mqPort
                                             heartbeat:mqHeartbeat userName:userName
                                              password:password vHost:mqVHost lifecycleDelegate:self];
self.connection.isLogin = FALSE;
self.connection.maxFrame = 65536;//64k
self.connection.readTimeout = 15;
NSError *error;
BOOL isSuccess = [self.connection connectionWithTimeout:3 error:&error];
if (isSuccess) {
    [self.connection startHeartbeat];//Yes, we keep a heartbeat
}

To consume a queue, what you need to do is implementing the AMQPConsumerDelegate protocol.

- (void)handleDelivery:(NSString *)consumerTag envelope:(Envelope *)envelope properties:(AMQPBasicProperties *)properties
              body:(NSData *)body {
   NSError *error = nil;
   NSLog(@"get message, length: %tu, type: %@", body.length, properties.contentType);
   if (![@"msg" isEqualToString:properties.contentType]) {
      [self.channel basicNAck:envelope.deliveryTag multiple:FALSE requeue:FALSE error:&error];
      return;
   }
   //...... PostSomeNotification(body);
   [self.channel basicAck:envelope.deliveryTag multiple:FALSE error:&error];
}

- (instancetype)initWith:(AMQPChannel *)channel {
   self = [super init];
   if (self) {
      self.channel = channel;
   }
   return self;
}

And also, you need to do like this, so you can receive the message.

NSString *consumeTag = [self.channel basicConsume:consumerQueue_ autoAck:FALSE delegate:consumer error:&error];


Just give it a try.
Thanks.

在 2015年9月4日星期五 UTC+8下午4:46:25,Rambabu写道:

Winston

unread,
Mar 31, 2016, 12:53:06 AM3/31/16
to rabbitmq-users
Installation by CocoaPods

pod 'LibRabbitMQ-OC', :git => 'https://github.com/fireflyc/LibRabbitMQ-OC', :tag=>'master'


在 2016年3月31日星期四 UTC+8下午12:29:06,Winston写道:
Reply all
Reply to author
Forward
0 new messages