Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On server processing

Tags:

coldfusion

I have a web application that will be doing some processing with submitted data. Instead of making the user wait for what will take at least a few seconds, maybe up to a few minutes during heavy load, I would like to know if there is some way to, within coldfusion, have processing that just occurs on the server.

Basically, the data would be passed to the server, and then the user would be redirected back to the main page to allow them to do other things, but not necessarily be able to see the results right away. Meanwhile, the processing of the data would take place on the server, and be entered into the database when complete.

Is this even possible within coldfusion, or would I need to look into using code that would receive the data and process it as a separate program?

like image 723
Computerman1597 Avatar asked Dec 16 '22 02:12

Computerman1597


2 Answers

ColdFusion 8 introduced the cfthread tag which may assist you.

 <cfthread 
    required 
    name="thread name" 
    optional 
    action="run" 
    priority="NORMAL|HIGH|LOW" 
    zero or more application-specific attributes> 

        Thread code 

    </cfthread> 
like image 148
Antony Avatar answered Jan 05 '23 04:01

Antony


To do this reliably, you can use a database table as a job queue. So you when the user submits the data you insert record into the database indicating there is some work to be done. Then you create a scheduled task in the CF Administrator that polls a script that gets the next job from the queue and does the processing you describe. When complete it can update the database and you can then alert your user that there job is complete.

Make sense?

like image 27
baynezy Avatar answered Jan 05 '23 03:01

baynezy