question

Upvotes
Accepted
3 0 0 0

RDP Question on News Python example

We’ve some quick questions regarding the news python example: 1) Does the code highlighted down below remove that news story from the SQS queue? My gut it that does from the following documentation I found: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sqs.html#SQS.Client.delete_message. Can you please confirm if the following is true? 2) We would like to be able to get a URL to the news story. How can we achieve this? We cannot see any obvious meta data which has this information! Sample Code. print('Polling messages from queue...') while 1: resp = sqs.receive_message(QueueUrl = endpoint, WaitTimeSeconds = 10) if 'n' in resp: messages = resp['Messages'] # print and remove all the nested messages for message in messages: mBody = message['Body'] # decrypt this message m = decrypt(cryptographyKey, mBody) processPayload(m, callback) # *** accumulate and remove all the nested message sqs.delete_message(QueueUrl = endpoint, ReceiptHandle = message['ReceiptHandle'])

pythonrdp-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
14.7k 39 12 18

Hi @shwetha.krishnaiah02,

Yes, in the RDP sample code, once the message is received, it is deleted from the queue. See the sqsQueue.py:

sqs.delete_message(QueueUrl = endpoint, ReceiptHandle = message['ReceiptHandle'])

For retrieving the news stories, you have two options -

1. Subscribe to news stories, instead of news headlines.

2. From the headline message, get the URN of the story (json tag: ecpMessageID), and use the stories endpoint from RDP to get the story body.

https://api.refinitiv.com/data/news/v1/stories/<STORY_URN>
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
23.5k 84 10 22

Hi @shwetha.krishnaiah02

I am guessing from the code snippet that you are referring to the rdp_python_samples file spsQueue.py

This example uses the Amazon AWS boto3 SDK and

  • looking at the boto3 documentation for the receive_message method
  • and given that we are dealing with a queue

it would make sense that retrieving a message from a queue would also remove the message from the queue.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.