[rabbitmq-discuss] RabbitMQ Cilent: Allow specifying the connect timeout

Amr Mostafa amr.mostafa at gmail.com
Wed Oct 27 13:19:55 BST 2010

Hi Emile,

Thank you very much, your response is much appreciated. It's great to know
we can expect to see this option (in the near future?).

As a side note: I would have been able to implement the first option you
suggested, except that I work with Spring AMQP. It's impossible to pass on a
custom ConnectionFactory instead of rabbit's own to it due to the lack of an
interface. If rabbit'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

Have a great day.

Best Regards,

On Wed, Oct 27, 2010 at 1:40 PM, Emile Joubert <emile at rabbitmq.com> wrote:

> Hi again Amr,
> On 27/10/10 12:01, Emile Joubert wrote:
> > Hi Amr,
> >
> > On 23/10/10 19:20, Amr Mostafa wrote:
> >> Hi,
> >>
> >> I've been searching around for a way to specify a connect timeout in the
> >> Java client, but couldn't find an easy way to do that. There is one way,
> >> which is by extending ConnectionFactory with a custom createFrameHandler
> >> method, but that doesn't work with my case since I'm using Spring AMQP
> >> support on top of the client API.
> >>
> >> It would be very useful to add an option for that in the
> >> ConnectionFactory which, if specified, would be passed to the socket
> >> connect call.
> >
> > You can also set socket options by overriding
> > ConnectionFactory.configureSocket(). By default this hook disables
> > Nagle's algorithm, but it can be used to set the timeout as well
> > (socket.setSoTimeout()). Even when using Spring AMQP you should be able
> > to specify your own ConnectionFactory that inherits from the existing
> one.
> My previous advice won't work, because SO_TIMEOUT doesn't affect the
> connection timeout. Instead of overriding configureSocket(), you need to
> override createFrameHandler(). The call to socket.connect(addr) needs to
> be changed to the 2-parameter version that accepts a connection timeout.
> Another option would be to supply your own SocketFactory that supplies
> sockets that override connect().
> Given the difficulty of both these options we will look at extending the
> ConnectionFactory API to make this simpler, as you suggested.
> Regards
> Emile

Amr Mostafa
Egypt Development Center
Member of NTG
Mobile: +(2012)1700502
Office: +(202)24052355/6 - Ext.: 2005
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20101027/7fd328c3/attachment.htm>

More information about the rabbitmq-discuss mailing list