using this library for ios rabbitmq client integration:&nbsp;https://github.com/bimawa/librabbitmq-objC<div><br></div><div>here is an iOS - obj C code:&nbsp;</div><div><br></div><div>







<p class="p1">}</p>
<p class="p1">-(<span class="s1">void</span>)establish{</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p3"><span class="s2">&nbsp; &nbsp; </span>AMQPConnection<span class="s2"> *connection = [[</span>AMQPConnection<span class="s2"> </span>alloc<span class="s2">] </span>init<span class="s2">];</span></p>
<p class="p1">&nbsp; &nbsp; <span class="s3">NSError</span> *error, *error1,*error2,*error3;</p>
<p class="p4"><span class="s2">&nbsp; &nbsp; [connection </span><span class="s3">connectToHost</span><span class="s2">:</span>&lt;hostname&gt;<span class="s2"> </span><span class="s3">onPort</span><span class="s2">:&lt;portno&gt;&nbsp;</span><span class="s3">error</span><span class="s2">:&amp;error] ? </span><span class="s3">NSLog</span><span class="s2">(</span>@"Connected to host"<span class="s2">):</span><span class="s3">NSLog</span><span class="s2">(</span>@"not connected to host"<span class="s2">);</span></p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p3"><span class="s2">&nbsp; &nbsp; [connection </span>loginAsUser<span class="s2">:</span><span class="s4">@"guest"</span><span class="s2"> </span>withPasswort<span class="s2">:</span><span class="s4">@"guest"</span></p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">onVHost</span>:<span class="s4">@"/"</span> <span class="s3">error</span>:&amp;error1];</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p1">&nbsp; &nbsp; <span class="s3">AMQPChannel</span> *channel = [connection <span class="s3">openChannel</span>];</p>
<p class="p3"><span class="s2">&nbsp; &nbsp; </span>AMQPExchange<span class="s2"> * exchange = [[</span>AMQPExchange<span class="s2"> </span>alloc<span class="s2">] </span>initExchangeWithName<span class="s2">:&lt;exchangename&gt;</span></p>
<p class="p1">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">onChannel</span>:channel];</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p3"><span class="s2">&nbsp; &nbsp; </span>AMQPQueue<span class="s2"> *queue = [[</span>AMQPQueue<span class="s2"> </span>alloc<span class="s2">] </span>initWithName<span class="s2">:</span><span class="s4">@"my_queue"</span><span class="s2"> </span>onChannel<span class="s2">:channel];</span></p>
<p class="p1">&nbsp; &nbsp; [queue <span class="s3">bindToExchange</span>:exchange <span class="s3">withKey</span>:<span class="s4">@"99999"</span> <span class="s3">error</span>:&amp;error3];</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p3"><span class="s2">&nbsp; &nbsp; </span>AMQPConsumer<span class="s2"> *consumer = [[</span>AMQPConsumer<span class="s2"> </span>alloc<span class="s2">] </span>initForQueue<span class="s2">:queue </span>onChannel<span class="s2">:&amp;channel</span></p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">useAcknowledgements</span>:<span class="s1">YES</span></p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">isExclusive</span>:<span class="s1">NO</span></p>
<p class="p1">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">receiveLocalMessages</span>:<span class="s1">NO</span></p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">error</span>:&amp;error2</p>
<p class="p1">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="s3">deepLoop</span>:5];</p>
<p class="p3"><span class="s2">&nbsp; &nbsp; </span>AMQPConsumerThread<span class="s2"> *consumerThread = [[</span>AMQPConsumerThread<span class="s2"> </span>alloc<span class="s2">] </span>initWithConsumer<span class="s2">:consumer </span>delegate<span class="s2">:(</span><span class="s1">id</span><span class="s2">)</span><span class="s1">self</span><span class="s2"> </span>nameThread<span class="s2">:</span><span class="s4">@"shivng_thread"</span><span class="s2">];</span></p>
<p class="p1">&nbsp; &nbsp; [consumerThread <span class="s3">start</span>];</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p2">&nbsp;&nbsp; &nbsp;</p>
<p class="p1">}</p>
<p class="p2"><br></p>
<p class="p1">-(<span class="s1">void</span>)amqpConsumerThreadReceivedNewMessage:(<span class="s3">AMQPMessage</span>*)theMessage{</p>
<p class="p1">&nbsp; &nbsp; <span class="s3">NSLog</span>(<span class="s4">@"message = %@"</span>, theMessage);</p>
<p class="p1">&nbsp; &nbsp; <span class="s3">NSLog</span>(<span class="s4">@"message.body = %@"</span>, theMessage.<span class="s3">body</span>);</p>
<p class="p1">}</p>
<p class="p1">-(<span class="s1">void</span>)amqpConsumerThreadLoseConnection{</p>
<p class="p4"><span class="s2">&nbsp; &nbsp; </span><span class="s3">NSLog</span><span class="s2">(</span>@"Consumer thread lost connection"<span class="s2">);</span></p>
<p class="p1">}</p>
<p class="p2">application just got hanged while calling :&nbsp;</p><p class="p2"><span class="s2">&nbsp;[connection&nbsp;</span>loginAsUser<span class="s2">:</span><span class="s4">@"guest"</span><span class="s2">&nbsp;</span>withPasswort<span class="s2">:</span><span class="s4">@"guest"</span></p><p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="s3">onVHost</span>:<span class="s4">@"/"</span>&nbsp;<span class="s3">error</span>:&amp;error1];</p><p class="p1"><br></p><p class="p1">the reason is, function:&nbsp;</p><p class="p1">







</p><p class="p1"><span class="s1">result = </span>recv<span class="s1">(state-&gt;</span>sockfd<span class="s1">, state-&gt;</span>sock_inbound_buffer<span class="s1">.</span>bytes<span class="s1">,state-&gt;</span>sock_inbound_buffer<span class="s1">.</span>len<span class="s1">, 0);</span></p><p class="p1">doesn't return back, just waiting waiting......</p><p class="p1">app waiting for executing next other statements after the above line...</p><p class="p1"><br></p></div><div><br><div><br></div><div><br></div></div>