We have an API to fetch the latest transaction data of the user based on the scheduled Next_Refresh_Time. Each user has different scheduled refresh time. Since we have thousands of users we have to run the scheduler to fetch the data. Please suggest me the best way to do it.
1 Answers
Each user has different scheduled refresh time. Since we have thousands of users we have to run the scheduler to fetch the data.
You could add a queue message and specify initialVisibilityDelay with Next_Refresh_Time
value when a user login, and then you could create and run a Queue-trigger WebJob to process queue message and featch the latest data (and if current user is still online, add the message (specify same content and initialVisibilityDelay as original message) to queue).
Besides, if you’d like to real-time push the latest data to specific connected user, SignalR would help you implement real-time functionality and SignalR can be used in a variety of client platforms. You could save connection id of a login user in queue message, and then you can call hub method in WebJob function to push data to a connected user based on connection id.
The following thread and article would be helpful to know how to establish connection and call hub method.

- 26,415
- 1
- 30
- 41
-
Thanks for your suggestion. The transaction API should be triggered from the background process. It doesn't matter whether the user is online or not and it is not real time push to the connected user. The data will be fetched from the API and it will be stored in the database. – Sarva Jun 20 '17 at 06:14
-
``The transaction API should be triggered from the background process.`` As I mentioned in the first part of my reply, you could add queue message for each user when user login or you add/create user, and then run Queue-trigger WebJob to process queue message and call API to fetch the latest data and store it in database. – Fei Han Jun 20 '17 at 08:46
-
I'm following your suggestion to achieve the task. The queue message didn't allow me to set the [NextVisibleTime](https://learn.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.queue.cloudqueuemessage.nextvisibletime?view=azure-dotnet#Microsoft_WindowsAzure_Storage_Queue_CloudQueueMessage_NextVisibleTime) because it is a read-only property. – Sarva Jun 21 '17 at 06:38
-
Hi @Sarva, sorry for point to a wrong property. I edited the reply, please try to specify initialVisibilityDelay when adding a message. – Fei Han Jun 21 '17 at 07:28
-
Hi @Fred, What should I do if the Next_Refresh_Time is more than a week or month. Since Storage queue persist messages only for 7 days what would be the alternate solution. Please help. – Sarva Aug 29 '17 at 19:23
-
If ``Next_Refresh_Time`` is more than a week or month, you can try to maintain datetime info specifying a scheduled time in message body, and you can compare it with current datetime when WebJob process the message, if it is ``that datetime filed - current datetime > 7 days``, resubmit same message to queue with 7 days initialVisibilityDelay. – Fei Han Aug 30 '17 at 09:10