Checking for new record in the DB - Server/RunTime error

Checking for new record in the DB - Server/RunTime error

  

Hi All,

I have written a javascript in Web Screen which triggers a screen action every 2 seconds.

Inside the Screen Action, I am checking If there is any new record in the DB. If there is a new record, I am refreshing the screen according to the new values. Until then, it keeps on checking for a new record and the process repeats. Refer the screenshot below


It works perfectly for few minutes and then I am getting the following error.


When I checked for the error in Service center, it says "Error executing query". Thread was being aborted it seems.


How to fix this issue? Please help!



Hi Anath,

this is related with this other topic

What you're doing is launching a new request each 2 seconds that is in a loop until a new record is found, What may cause multiple requests (launched at 2s, 4s, 6s, 8s...) to be in loop at the same time. I have two  suggestions. 

1. In the displayed flow change the False branch of the IF to an END node.

2. If you're still using the WS, call it here instead of the aggregate. No need to have the timer in a loop populating the table that you use here.



Cheers,

Tiago.

Ananth wrote:

Tiago Gafeira wrote:

Hi Anath,

this is related with this other topic

What you're doing is launching a new request each 2 seconds that is in a loop until a new record is found, What may cause multiple requests (launched at 2s, 4s, 6s, 8s...) to be in loop at the same time. I have two  suggestions. 

1. In the displayed flow change the False branch of the IF to an END node.

2. If you're still using the WS, call it here instead of the aggregate. No need to have the timer in a loop populating the table that you use here.



Cheers,

Tiago.

Sorry for my wrong description. The screenshot I post is my current implementation. I am just calling that action only once using javascript.


1. In the displayed flow change the False branch of the IF to an END node. -- I tried this previously. I was still getting the same error. :-(

this other topic. - This one related to that server action which is triggered by a timer.

This post is regarding the WebScreen screen action in which no timer is involved. It is waiting for new records in the DB created by the server action. Got it?










Sorry for my wrong description. The screenshot I post is my current implementation. I am just calling that action only once using javascript.


Even if you're calling it only once and not every 2 seconds, having that kind of loop is a bad practice as it is hammering the DB and using Server Reources intensively with  absolute no control. Regarding this part of the solution, avoiding the loop is the only way to go.

1. In the displayed flow change the False branch of the IF to an END node. -- I tried this previously. I was still getting the same error. :-(

Maybe something else is also contributing for the problem. But that doesn't mean that you need to avoid the loop.

this other topic. - This one related to that server action which is triggered by a timer.

This post is regarding the WebScreen screen action in which no timer is involved. It is waiting for new records in the DB created by the server action. Got it?

The other topic about the timer and the call to the WS is not related to the DB value you read in the Web Screen action?










Tiago Gafeira wrote:



Sorry for my wrong description. The screenshot I post is my current implementation. I am just calling that action only once using javascript.


Even if you're calling it only once and not every 2 seconds, having that kind of loop is a bad practice as it is hammering the DB and using Server Reources intensively with  absolute no control. Regarding this part of the solution, avoiding the loop is the only way to go.

1. In the displayed flow change the False branch of the IF to an END node. -- I tried this previously. I was still getting the same error. :-(

Maybe something else is also contributing for the problem. But that doesn't mean that you need to avoid the loop.

this other topic. - This one related to that server action which is triggered by a timer.

This post is regarding the WebScreen screen action in which no timer is involved. It is waiting for new records in the DB created by the server action. Got it?

The other topic about the timer and the call to the WS is not related to the DB value you read in the Web Screen action?














The other topic about the timer and the call to the WS is not related to the DB value you read in the Web Screen action? -- Yes, It is related to that only.

If this overloading the server, Can you please suggest me the optimal way to do this?



Solution

Already tried, but here it goes.

1. Get rid of the timer.

2. In the web screen call a screen action (by clicking a hidden button with method set to Ajax Submit) every X seconds.

3. Change the screen action flow:

3.1 Replace the Aggregate to a call to the WS

3.2 In the IF test the result of the WS, and if no action is required, go to an END node.


Solution

If integration with a firebase (or similar) is acceptable you can use a process that is triggered when new records is added to the entity and use web sockets to notify application that new record is added and it will refresh the screen.

Mykola (Nick) Tkachenko wrote:

If integration with a firebase (or similar) is acceptable you can use a process that is triggered when new records is added to the entity and use web sockets to notify application that new record is added and it will refresh the screen.

This is next to ideal, avoiding the cost of pooling in the consumer. If it is an option, go for it.


Hi Ananth,

Any update?

Tiago Gafeira wrote:

Already tried, but here it goes.

1. Get rid of the timer.

2. In the web screen call a screen action (by clicking a hidden button with method set to Ajax Submit) every X seconds.

3. Change the screen action flow:

3.1 Replace the Aggregate to a call to the WS

3.2 In the IF test the result of the WS, and if no action is required, go to an END node.


Hi Tiago,

Thanks for your suggestions.
2. In the web screen call a screen action (by clicking a hidden button with method set to Ajax Submit) every X seconds - We have done the same. It is working fine now.