[rabbitmq-discuss] RabbitMQ C library function amqp_simple_wait_frame takes 400 ms

David Wragg david at rabbitmq.com
Sat Jun 26 00:54:19 BST 2010


Hi Jim,

Jim Irrer <irrer at umich.edu> writes:
> I'm working on two functions that act as a client-server pair.  They
> use two amq.direct queues to communicate.  When ever either of
> them calls the amqp_simple_wait_frame function, it does not return
> for 436618 microseconds.
>
> Some other background info that might be relevant:
>
> If I only send messages in one direction it's really fast.
>
> Both processes are using separate connectors and different sockets.
>
> I used the amqp_consumer.c amqp_producer.c code in
> the examples directory as a reference.
>
> Is there a way to avoid this delay?

I'm not sure what you are really asking here.  As its name suggests,
amqp_simple_wait_frame waits for a frame to arrive.  It will typically
attempt to read from the socket connected to the AMQP server.  If no
data is available, it will block until data is available.  The resulting
delays are thus an intrinsic feature of amqp_simple_wait_frame.

Are you sure that the 400ms delay does not simply reflect the wait for a
message to arrive?

I'm guessing, but perhaps the problem is that you want a single
application to publish and consume messages concurrently, and you are
finding that the synchronous nature of amqp_simple_wait_frame is an
obstacle?  If so, the simplest work around would be to have two threads,
one to publish and one to consume, and open a separate AMQP connection
in each thread.

> Also ...
>
> Could I use the same socket in each program as long as it was only
> used by one thread at a time?
>
> Could I use the same connection in each program if it was only
> used by one thread at a time?

What's the distinction between socket and connection here?

librabbitmq does not do anything to explicitly support multithreading,
but neither does it do anything to conflict with it.  If you, the
application programmer, ensure that for a given connection, only one
thread uses librabbitmq at a time, you should be safe.

-- 
David Wragg
Staff Engineer, RabbitMQ
SpringSource, a division of VMware


More information about the rabbitmq-discuss mailing list