Learn R Programming

aws.sqs (version 0.1.10)

receive_msg: Receive messages

Description

Receive one or more messages from an SQS queue.

Usage

receive_msg(queue, attributes = NULL, n = 1, timeout = NULL,
  wait = NULL, query = NULL, ...)

consume_msg(queue, receive_args = list(), delete_args = list())

delete_msg(queue, handle, query = NULL, ...)

Arguments

queue

A character string containing a queue URL, or the name of the queue.

attributes

Currently ignored.

n

The number of messages to retrieve (maximum 10).

timeout

A number of seconds to make the message invisible to subsequent receive_msg requests. This modifies the queue's default visibility timeout. See visibility to modify this value after receiving a message.

wait

A number of seconds to wait for messages before responding to the request.

query

A list specifying additional query arguments to be passed to the query argument of sqsHTTP.

...

Additional arguments passed to sqsHTTP.

receive_args

A named list of arguments, other than queue, to be passed to receive_msg.

delete_args

A named list of arguments, other than queue and handle, to be passed to delete_msg.

handle

A message handle, as returned by receive_msg.

Value

A data.frame of messages.

Details

receive_msg simply receives message(s). consume_msg does the same and then deletes the message(s) from the queue. delete_message deletes one or more messages from an SQS queue. If a message is not deleted, it remains visible in the queue and will be returned by subsequent calls to receive_msg.

References

ReceiveMessage DeleteMessage DeleteMessageBatch

See Also

link{send_msg}

Examples

Run this code

  # list current queues
  list_queues()
  
  # create a queue
  queue <- create_queue("ExampleQueue")
  get_queue_url("ExampleQueue")
  
  # send message to queue
  send_msg("ExampleQueue", "This is a test message")
  # receive a message
  (m <- receive_msg("ExampleQueue", timeout = 0))
  
  # delete a message from queue
  delete_msg("ExampleQueue", m$ReceiptHandle[1])
  
  # delete queue
  delete_queue("ExampleQueue")
  

Run the code above in your browser using DataLab