<div class="gmail_quote"><br><br>��Hi guys ,<div>�� � � � � � �I am using RabbitMQ version 2.3 on server and in code I am using java RabbitMQ client jar 2.3.1.</div><div><br></div><div>�� � � � � � �The whole application is in Scala in which there are 10 actors each has its own �Queue on RabbitMQ �Server.</div>

<div>�� � � � � � � each Actor is accessing its Queue through its own methods like get Message and addMessage.</div><div>�� � � � � � � In Attachment I have �attached One sample code for Actor methods .</div><div>�� � � � � � ��</div>

<div>�� � � � � � � in every actor continuously checks for any Message in queue like�</div><div>�� � � � � � � ��</div><div><br></div><div><ol><li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#FF0000">�� � </font><font color="#3366FF"><font face="&#39;arial black&#39;, sans-serif">�</font><font face="&#39;arial black&#39;, sans-serif">def act {</font></font></li>

<li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � this ! 1</font></li><li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � �loop {</font></li>

<li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � � �react {</font></li><li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � � � � � �case 1 =&gt; processMessage(QueueManager.getMessage); this ! 1</font></li>

<li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � �</font></li><li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � � � � � � }</font></li>

<li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � � � � � }</font></li><li style="text-align:left"><font face="&#39;arial black&#39;, sans-serif" color="#3366FF">�� � � � � � � � � � �}</font></li>

</ol><div><br></div><div>�� � � � �this works fine ..But sometimes it gives me error like�</div><div><br></div><div><span style="font-family:arial, sans-serif;font-size:13px">�<font color="#FF6600">Exception in Creating Rabbit MQ Connection<br>

java.net.ConnectException: Connection timed out<br>� � � �at java.net.PlainSocketImpl.socketConnect(Native Method)<br>� � � �at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310)<br>� � � �at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176)<br>

� � � �at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)<br>� � � �at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)<br>� � � �at java.net.Socket.connect(Socket.java:546)<br>� � � �at java.net.Socket.connect(Socket.java:495)<br>

� � � �at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:338)<br>� � � �at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:376)<br>� � � �at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:399)</font></span></div>

<div><br></div><div><br></div><div>�� �The server is running on its default port 5672. and actors are running on same machine .</div><div>�the QueueManager is�</div><div><br></div><div><div><font color="#3366FF">object QueueManager {</font></div>

<div><font color="#3366FF">��private val logger: Logger = Logger.getLogger(this.getClass.getName)</font></div><div><font color="#3366FF">��private val FACTORY = RabbitMQConstants.getFactory</font></div>
<div><font color="#3366FF"><br></font></div><div><font color="#3366FF">��private var conn: Connection = null</font></div><div><font color="#3366FF">��private var channel: Channel = null</font></div>
<div><font color="#3366FF">�</font></div><div><font color="#3366FF">��/**</font></div><div><font color="#3366FF">�� * @return</font></div><div><font color="#3366FF">�� * com.prolinkd.actor.QueueObject</font></div>
<div><font color="#3366FF">�� * reads a Message from rabbitMQ Queue</font></div><div><font color="#3366FF">�� */</font></div><div><font color="#3366FF">��def getMessage: QueueObject = synchronized{</font></div>
<div><font color="#3366FF">�� �if (conn == null || (channel != null &amp;&amp; (!channel.isOpen))) {</font></div><div><font color="#3366FF">�� � �getConnection</font></div>
<div><font color="#3366FF">�� � �if (conn == null) {</font></div><div><font color="#3366FF">�� � � �return null</font></div><div><font color="#3366FF">�� � �}</font></div>
<div><font color="#3366FF">�� �}</font></div><div><font color="#3366FF">�� �var obj = new ConnectionObject</font></div><div><font color="#3366FF">�� �try {</font></div>
<div><font color="#3366FF">�� � �val response = channel.basicGet(CONNECTION_QUEUE, false)</font></div><div><font color="#3366FF">�� � �if (response == null) return null</font></div>
<div><font color="#3366FF">�� � �val msg = new java.io.ObjectInputStream(</font></div><div><font color="#3366FF">�� � � �new java.io.ByteArrayInputStream(response.getBody)).readObject()</font></div>
<div><font color="#3366FF">�� � �obj = msg.asInstanceOf[ConnectionObject]</font></div><div><font color="#3366FF">�� � �channel.basicAck(response.getEnvelope().getDeliveryTag(), false)</font></div>
<div><font color="#3366FF">�� �} catch {</font></div><div><font color="#3366FF">�� � �case e: Exception =&gt; logger.error(&quot;error in Get Message&quot;, e); //endConnection</font></div>
<div><font color="#3366FF">�� �}</font></div><div><font color="#3366FF">�� �//endConnection</font></div><div><font color="#3366FF">�� �obj</font></div>
<div><font color="#3366FF">��}</font></div><div><font color="#3366FF">�</font></div><div><font color="#3366FF"><br></font></div><div><font color="#3366FF">��/**</font></div>
<div><font color="#3366FF">�� * Get Connected with RabbitMQ Server</font></div><div><font color="#3366FF">�� */</font></div><div><font color="#3366FF">��private def getConnection {</font></div>
<div><font color="#3366FF">�� �try {</font></div><div><font color="#3366FF">�� � �conn = FACTORY.newConnection</font></div><div><font color="#3366FF">�� � �if (conn == null) {</font></div>
<div><font color="#3366FF">�� � � �<a href="http://logger.info" target="_blank">logger.info</a>(&quot; FAILED TO CREATE CONNECTION WITH RABBITMQ ON �&quot; + FACTORY.getHost + &quot;:&quot; + FACTORY.getPort)</font></div>

<div><font color="#3366FF">�� � �}</font></div><div><font color="#3366FF">�� � �channel = conn.createChannel</font></div><div><font color="#3366FF">�� � �if (channel == null) {</font></div>
<div><font color="#3366FF">�� � � �<a href="http://logger.info" target="_blank">logger.info</a>(&quot; FAILED TO CREATE CHANNEL WITH RABBITMQ ON �&quot; + FACTORY.getHost + &quot;:&quot; + FACTORY.getPort)</font></div>
<div><font color="#3366FF">�� � �}</font></div><div><font color="#3366FF">�� � �if (conn != null) {</font></div><div><font color="#3366FF">�� � � �val durable = true</font></div>
<div><font color="#3366FF">�� � � �channel.exchangeDeclare(CONNECTION_EXCHANGE, &quot;direct&quot;, durable)</font></div><div><font color="#3366FF">�� � � �channel.queueDeclare(CONNECTION_QUEUE, durable, false, false, null)</font></div>

<div><font color="#3366FF">�� � � �channel queueBind (CONNECTION_QUEUE, CONNECTION_EXCHANGE, CONNECTION_ROUTING_KEY)</font></div><div><font color="#3366FF">�� � �}</font></div>
<div><font color="#3366FF">�� �} catch {</font></div><div><font color="#3366FF">�� � �case e: Exception =&gt; logger.error(&quot;Exception In Getting Connection to RabbitMQ &quot;, e)</font></div>
<div><font color="#3366FF">�� �}</font></div><div><font color="#3366FF"><br></font></div><div><font color="#3366FF">��}</font></div><div><font color="#3366FF"><br>
</font></div><div><font color="#3366FF">}</font></div></div><div><font color="#3366FF"><br></font></div><div><br></div><div>we can&#39;t figure out the particular issue.can you guys �help us please</div>
<br>-- <br>Regards,<br>Sagar<br>
</div>
</div><br><br>