module Netamqp_basic:Sending and receiving messages via a queuesig
..end
class type message =object
..end
val create_message : ?content_type:string ->
?content_encoding:string ->
?headers:Netamqp_rtypes.table ->
?delivery_mode:int ->
?priority:int ->
?correlation_id:string ->
?reply_to:string ->
?expiration:string ->
?message_id:string ->
?timestamp:float ->
?typ:string ->
?user_id:string ->
?app_id:string -> Xdr_mstring.mstring list -> message
Netamqp_basic.message
for documentation of the optional header fields.
The unnamed argument is the body.
val qos_e : channel:Netamqp_channel.channel_obj ->
?prefetch_size:int ->
?prefetch_count:int -> ?global:bool -> unit -> unit Uq_engines.engine
val qos_s : channel:Netamqp_channel.channel_obj ->
?prefetch_size:int -> ?prefetch_count:int -> ?global:bool -> unit -> unit
global=true
).
prefetch_size
: Sets the prefetch window in octetsprefetch_count
: Sets the prefetch window in number of messagesval consume_e : channel:Netamqp_channel.channel_obj ->
queue:Netamqp_queue.queue_name ->
?consumer_tag:string ->
?no_local:bool ->
?no_ack:bool ->
?exclusive:bool ->
?no_wait:bool ->
?arguments:Netamqp_rtypes.table -> unit -> string Uq_engines.engine
val consume_s : channel:Netamqp_channel.channel_obj ->
queue:Netamqp_queue.queue_name ->
?consumer_tag:string ->
?no_local:bool ->
?no_ack:bool ->
?exclusive:bool ->
?no_wait:bool -> ?arguments:Netamqp_rtypes.table -> unit -> string
Arguments:
queue
: The queue to consume fromconsumer_tag
: Identifies the consumer. If empty or omitted,
the server creates a unique identifierno_local
: Do not receive messages that were published over
this connectionno_ack
: Do not expect acknowledgements for consumed messagesexclusive
: Request exclusive access to the queueno_wait
: whether not to wait for the response of the request.
This is faster, but errors are not immediately reported,
and automatically created consumer tags cannot be returned to
the client.arguments
: Depends on the server implementationval cancel_e : channel:Netamqp_channel.channel_obj ->
consumer_tag:string -> ?no_wait:bool -> unit -> string Uq_engines.engine
val cancel_s : channel:Netamqp_channel.channel_obj ->
consumer_tag:string -> ?no_wait:bool -> unit -> string
consumer_tag
. This does not
affect already delivered messages, but it does mean the server
will not send any more messages for that consumer. The client
may receive an arbitrary number of messages in between sending
the cancel method and receiving the cancel-ok reply.
Arguments:
consumer_tag
: The consumer to cancelno_wait
: whether not to wait for the response of the request.
This is faster, but errors are not immediately reported.val publish_e : channel:Netamqp_channel.channel_obj ->
exchange:Netamqp_exchange.exchange_name ->
routing_key:string ->
?mandatory:bool ->
?immediate:bool -> message -> unit Uq_engines.engine
val publish_s : channel:Netamqp_channel.channel_obj ->
exchange:Netamqp_exchange.exchange_name ->
routing_key:string ->
?mandatory:bool -> ?immediate:bool -> message -> unit
Arguments:
exchange
: Name of exchange to send the message torouting_key
: The routing key for the exchangemandatory
: This flag tells the server how to react if the message
cannot be routed to a queue. If this flag is set, the server will
return an unroutable message with a Return method. If this flag is
false, the server silently drops the message.immediate
: This flag tells the server how to react if the message cannot be
routed to a queue consumer immediately. If this flag is set, the
server will return an undeliverable message with a Return method.
If this flag is false, the server will queue the message, but with
no guarantee that it will ever be consumed.val on_return : channel:Netamqp_channel.channel_obj ->
cb:(reply_code:int ->
reply_text:string ->
exchange:Netamqp_exchange.exchange_name ->
routing_key:string -> message -> unit) ->
unit -> unit
cb
is called back whenever a
message is returned to the client. The handler remains active
as long as the channel is open.
Arguments of the callback:
reply_code
: Reason for return, as error codereply_text
: Reason for return, as error textexchange
: the exchange the message was originally published
to. May be empty, meaning the default exchange.routing_key
: the routing key name specified when the message was
publishedval on_deliver : channel:Netamqp_channel.channel_obj ->
cb:(consumer_tag:string ->
delivery_tag:Rtypes.uint8 ->
redelivered:bool ->
exchange:Netamqp_exchange.exchange_name ->
routing_key:string -> message -> unit) ->
unit -> unit
cb
is called back whenever a
message is delivered to the client. The handler remains active
as long as the channel is open.
Arguments of the callback:
consumer_tag
: The name of the consumer to which this delivery
refers todelivery_tag
: A unique name of this delivery. Needed for
acknowledging the messageredelivered
: indicates that the message has been previously
delivered to this or another clientexchange
: the exchange the message was originally published
to. May be empty, meaning the default exchange.routing_key
: the routing key name specified when the message was
publishedtype'a
get_message =out:(delivery_tag:Rtypes.uint8 ->
redelivered:bool ->
exchange:Netamqp_exchange.exchange_name ->
routing_key:string ->
message_count:Rtypes.uint4 -> message -> 'a) ->
unit -> 'a
get
is returned by providing this function to the caller.
When this function is called with an out
argument, it will immediately
call out
back with the result values. The return value of cb
is
the return value of get_message
.
Arguments of out
:
delivery_tag
: A unique name of this delivery. Needed for
acknowledging the messageredelivered
: indicates that the message has been previously
delivered to this or another clientexchange
: the exchange the message was originally published
to. May be empty, meaning the default exchange.routing_key
: the routing key name specified when the message was
publishedmessage_count
: ?type'a
get_result =[ `Empty | `Message of 'a get_message ]
get
can return a message, or indicate that the queue
is emptyval get_e : channel:Netamqp_channel.channel_obj ->
queue:Netamqp_queue.queue_name ->
?no_ack:bool -> unit -> 'a get_result Uq_engines.engine
val get_s : channel:Netamqp_channel.channel_obj ->
queue:Netamqp_queue.queue_name ->
?no_ack:bool -> unit -> 'a get_result
Arguments:
queue
: the name of the queueno_ack
: Do not expect acknowledgements for consumed messagesget_result
. For
example, to just get the message:
let get_result = get_s ... () in
match get_result with
| `Empty -> failwith "No message on the queue"
| `Message get_msg ->
let message =
get_msg
~out:(fun ~delivery_tag ~redelivered ~exchange ~routing_key
~message_count message ->
message
)
() in
...
val ack_e : channel:Netamqp_channel.channel_obj ->
delivery_tag:Rtypes.uint8 -> ?multiple:bool -> unit -> unit Uq_engines.engine
val ack_s : channel:Netamqp_channel.channel_obj ->
delivery_tag:Rtypes.uint8 -> ?multiple:bool -> unit -> unit
delivery_tag
.
Note that this is an async operation,
and when this function is finished, this only means that the request
has been written to the socket, but not more.
Arguments:
multiple
: If set, the delivery tag is treated as "up to and
including", so that the client can acknowledge multiple messages
with a single method.val reject_e : channel:Netamqp_channel.channel_obj ->
delivery_tag:Rtypes.uint8 -> requeue:bool -> unit -> unit Uq_engines.engine
val reject_s : channel:Netamqp_channel.channel_obj ->
delivery_tag:Rtypes.uint8 -> requeue:bool -> unit -> unit
Arguments:
delivery_tag
: identifies the message to rejectrequeue
: Requeue the message. The message is never sent again to
this channel.val recover_e : channel:Netamqp_channel.channel_obj ->
requeue:bool -> unit -> unit Uq_engines.engine
val recover_s : channel:Netamqp_channel.channel_obj -> requeue:bool -> unit -> unit
Arguments:
requeue
: If this field is false, the message will be redelivered
to the original recipient. If this bit is set, the server will attempt
to requeue the message,
potentially then delivering it to an alternative subscriber.