<div dir="ltr">Hi Emile,<br><br>Thank you very much, your response is much appreciated. It&#39;s great to know we can expect to see this option (in the near future?).<br><br>As a side note: I would have been able to implement the first option you suggested, except that I work with Spring AMQP. It&#39;s impossible to pass on a custom ConnectionFactory instead of rabbit&#39;s own to it due to the lack of an interface. If rabbit&#39;s ConnectionFactory was an interface, Spring AMQP (and other frameworks) could use that interface instead of the direct implementation, thus, allowing framework users to pass on custom connection factories.<br>

<br>Have a great day.<br><br>Best Regards,<br><br><div class="gmail_quote">On Wed, Oct 27, 2010 at 1:40 PM, Emile Joubert <span dir="ltr">&lt;<a href="mailto:emile@rabbitmq.com">emile@rabbitmq.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi again Amr,<br>
<div><div></div><div class="h5"><br>
On 27/10/10 12:01, Emile Joubert wrote:<br>
&gt; Hi Amr,<br>
&gt;<br>
&gt; On 23/10/10 19:20, Amr Mostafa wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve been searching around for a way to specify a connect timeout in the<br>
&gt;&gt; Java client, but couldn&#39;t find an easy way to do that. There is one way,<br>
&gt;&gt; which is by extending ConnectionFactory with a custom createFrameHandler<br>
&gt;&gt; method, but that doesn&#39;t work with my case since I&#39;m using Spring AMQP<br>
&gt;&gt; support on top of the client API.<br>
&gt;&gt;<br>
&gt;&gt; It would be very useful to add an option for that in the<br>
&gt;&gt; ConnectionFactory which, if specified, would be passed to the socket<br>
&gt;&gt; connect call.<br>
&gt;<br>
&gt; You can also set socket options by overriding<br>
&gt; ConnectionFactory.configureSocket(). By default this hook disables<br>
&gt; Nagle&#39;s algorithm, but it can be used to set the timeout as well<br>
&gt; (socket.setSoTimeout()). Even when using Spring AMQP you should be able<br>
&gt; to specify your own ConnectionFactory that inherits from the existing one.<br>
<br>
</div></div>My previous advice won&#39;t work, because SO_TIMEOUT doesn&#39;t affect the<br>
connection timeout. Instead of overriding configureSocket(), you need to<br>
override createFrameHandler(). The call to socket.connect(addr) needs to<br>
be changed to the 2-parameter version that accepts a connection timeout.<br>
<br>
Another option would be to supply your own SocketFactory that supplies<br>
sockets that override connect().<br>
<br>
Given the difficulty of both these options we will look at extending the<br>
ConnectionFactory API to make this simpler, as you suggested.<br>
<br>
Regards<br>
<font color="#888888"><br>
Emile<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Amr Mostafa<br>Egypt Development Center<br>Member of NTG<br>Mobile: +(2012)1700502<br>Office: +(202)24052355/6 - Ext.: 2005<br>
</div>