We cannot get items by multiple Batch Request

Hi Team,

I'm going to send request for 4000+ items. So divide items for multiple batch request like below, by reference

(_send_market_price_request is called after getting login response correctly.)

class ReutersReceiver:
def _send_market_price_request(self):
# get 4000+ items
all_rics = get_ric_list()
# each batch request has 3500 items
MAX_LIST_LEN = 3500
def get_req_json(rics):
return {
'ID': 2,
'Domain': 'MarketPrice',
'Key': {
'NameType': 'Ric',
'Name': rics,
},
'View':get_view_items_list(),
}

for top_num in range(0, len(all_rics), MAX_LIST_LEN):
_rics = all_rics[top_num:top_num + MAX_LIST_LEN]
self.web_socket_app.send(json.dumps(get_req_json(_rics)))
time.sleep(5)

Only 3447/4678 Refresh message has be returned and as items increase the time first Update message has arrived increase, even though each batch request item size is around 55kb.

Also, the more increasing size, the worse returned Refresh/Update message.

Are there anything bad implementations or other factor?

Or what should I do if there is no simple resolution. Could you give me some workaround?


Thanks


mochizuki.y



Tagged:

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @mochizuki.y

    According to the code, you use the same streamID for batch requests which is incorrect.

    The streamID must be unique for each stream. The following picture shows how the streamID works in a batch request.

    1655194393758.png

    The picture uses the streamID: 4 for a batch request which requests three items.

    The server will close the batch request (streamID: 4) with the stream state: Closed and the data state: Ok. Then, the server will send unique streamIDs (5, 6, 7) for each subscribed item.

    Therefore, if the application would like to send another batch stream, the streamID of the new batch request should be 8.

    In your case, you use the streamId: 2 for a batch request to subscribe to 3500 items so the streamID of the next batch request should be 3503 (2+3500+1).

Answers

  • @Jirapongse

    Thank you for your advice. Now we have confirmed to get 4000+ items by multiple batch requests which are assigned streamID dynamically.