question

Upvotes
Accepted
5 2 2 7

Delete record on non-interactive source with an OMM off-stream post (websocket)

Hi - how do I delete a specific record using an OMM off-stream post on the ads web socket please?

I'm using a type "Update" with an Action "Delete" - I get an Ack back from the ads, but the record doesn't get deleted.

How do I remove it from cache please with a post?

Thanks

Martin

python#technology#productwebsocketsADHposting
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
27.6k 67 18 14

Hello @martin.gregory

Thank you for contacting us. Based on the Real-Time WebSocket API specification document, the POST and the Market Price domain messages do not have an "Action" attribute. Which data domain you are posting and want to delete the upstream cache?

However, you can post the status message with state and text information that the item stream is closed because the item has been deleted to replace that cache data as follows:

mp_post_json = {
            'ID': <Stream ID based on your onstream or offstream post>,
            'Type':'Post',
            'Domain':'MarketPrice',
            'Ack':True,
            'PostID':post_id,
            'PostUserInfo': {
                'Address':position,  # Use IP address as the Post User Address.
                'UserID':os.getpid() # Use process ID as the Post User Id.
            },
            'Key': {
                'Name': '<Item Name>',
                'Service': '<Service Name>'
            },
            'Message': {
                'ID': 0,
                'Type':'Status',
                'State': {
                    'Stream': 'Closed',
                    'Data': 'Suspect',
                    'Code': 'None',
                    'Text': '***Item Deleted'
                }
            }
        }

Example from the WebSocket Python examples (market_price.py and market_price_posting.py)

Firstly, the market_price_posting.py posts the Update message to my local RTDS.

SENT:
{
  "Ack":true,
  "Domain":"MarketPrice",
  "ID":1,
  "Key":{
    "Name":"POST.ITEM",
    "Service":"DIST_CACHE"
  },
  "Message":{
    "Domain":"MarketPrice",
    "Fields":{
      "ASK":54.57,
      "ASKSIZE":28,
      "BID":54.55,
      "BIDSIZE":27
    },
    "ID":0,
    "Type":"Update"
  },
  "PostID":10,
  "PostUserInfo":{
    "Address":"192.168.68.111",
    "UserID":14492
  },
  "Type":"Post"
}RECEIVED:
[
  {
    "AckID":10,
    "ID":1,
    "Type":"Ack"
  }
]

Next, the market_price.py gets updated for RIC POST.ITEM from my local RTDS

RECEIVED: 
[
  {
    "Fields":{
      "ASK":54.57,
      "ASKSIZE":28,
      "BID":54.55,
      "BIDSIZE":27
    },
    "ID":2,
    "Key":{
      "Name":"POST.ITEM",
      "Service":"DIST_CACHE"
    },
    "PostUserInfo":{
      "Address":"192.168.68.111",
      "UserID":14492
    },
    "Type":"Update",
    "UpdateType":"Unspecified"
  }
]

Then, the market_price_positng.py posts Status close to my local RTDS

SENT:
{
  "Ack":true,
  "Domain":"MarketPrice",
  "ID":1,
  "Key":{
    "Name":"POST.ITEM",
    "Service":"DIST_CACHE"
  },
  "Message":{
    "ID":0,
    "State":{
      "Code":"None",
      "Data":"Suspect",
      "Stream":"Closed",
      "Text":"***Item Deleted"
    },
    "Type":"Status"
  },
  "PostID":11,
  "PostUserInfo":{
    "Address":"192.168.68.111",
    "UserID":14492
  },
  "Type":"Post"
}
RECEIVED:
[
  {
    "AckID":11,
    "ID":1,
    "Type":"Ack"
  }
]

Finally, the market_price.py get this status close message for a POST.ITEM RIC.

RECEIVED: 
[
  {
    "ID":2,
    "Key":{
      "Name":"POST.ITEM",
      "Service":"DIST_CACHE"
    },
    "PostUserInfo":{
      "UserID":14492
    },
    "State":{
      "Data":"Suspect",
      "Stream":"Closed",
      "Text":"****Item Deleted"
    },
    "Type":"Status"
  }
]

I hope this information helps.

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.

Thanks Wasin, that's exactly what I needed. Test item successfully removed from adh cache


Thanks

Martin

Hello @martin.gregory

Please be informed that if a consumer application continues requesting that data, the app gets "Closed / Suspect / None / 'F10: Not In Cache'" from the backend until the post-consumer app posts image/update messages again.

Thanks Wasin, understood.

I've tested resending the image and the record is now back, so everything is behaving as expected

Thanks

Martin

Upvote
25.4k 90 13 25

Hi @martin.gregory

You may already be aware and I don't know if this would be relevant to your particular implementation...
However, I just thought I would mention that the ADH can be configured to automatically expire records in an NI Cache service.
Learn how to create auto-expiring records on Refinitiv Real-Time | Devportal -

extract....

There may be a scenario where you want to create records on Refinitiv Real-Time for other users within your organisation to consume for a limited time only or maintain a cache of a limited size. For example:

  • The content is only valid for a limited period of time, after which you do not wish anyone to consume the record
  • You wish to keep a rolling history of events for a given period e.g. past 24hrs or past 7 days
  • Only keep a configured number of records in the cache and drop the oldest when the item count is exceeded

...

The ADH component of Refinitiv Real-Time offers the facility to Auto expire records from its user-populated cache after a given period of time or when a maximum cache size is exceeded. So, for example, you could specify that a record is dropped 24hrs after it was created or updated OR drop the oldest record when the cache size exceeds a configured number.

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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