mazraara
(Mazraara)
September 27, 2012, 7:03am
1
[size="4"]Hi Friends, i would like to know… does Yii supports Asynchronous script execution or multi threading ?
I am in a situation of sending 4 ( to : accounting det, user, created-person, admin) emails when a user update the profile.
I am almost done with my requirement but unfortunately the php page takes too much time, more than 12 seconds to load which is not a good practice.
can somebody please suggest me someway of achieving this task in less time ? any help would be highly appreciated.
Please note : in each email, content is different from one another.
Thanks in advance. [/size]
mazraara
(Mazraara)
September 27, 2012, 7:08am
2
anyone there to help me out ?
Long-lasting tasks can usually be processed by crontab (after updating the profile you add a task to some queue and then cron + console app do the rest).
But… 12 seconds for email?? It’s too much, you know.
mazraara
(Mazraara)
September 27, 2012, 7:31am
4
Long-lasting tasks can usually be processed by crontab (after updating the profile you add a task to some queue and then cron + console app do the rest).
But… 12 seconds for email?? It’s too much, you know.
Yeah i know, that’s why i am worried about.
do you have any other suggestion than a cron job to use ??
thanks for you comment ORey.
I believe that cron is the best fit for such tasks, it’s bulletproof.
So no, no other suggestion.
Hmm, seems like I have one.
Figure out what’s going on with your mailer
Treatment of symptoms is not the best practice.
mazraara
(Mazraara)
September 27, 2012, 7:53am
7
Hmm, seems like I have one.
Figure out what’s going on with your mailer
Treatment of symptoms is not the best practice.
just a php mail function is used.
zaccaria
(Matteo Falsitta)
September 27, 2012, 7:59am
8
You can create a table in which save what email to send.
As you did it, you can create a console command (read the guide about console application) that looks in this table and send the needed email.
With cron you can call this console command every 5 minutes.
alex-w
(Pr0j3ct A1ex)
September 27, 2012, 7:59am
9
I would if possible use ajax.
Ajax Request -> Send Email in PHP -> Output result -> Next Ajax Request
mazraara
(Mazraara)
September 27, 2012, 8:05am
10
zaccaria:
You can create a table in which save what email to send.
As you did it, you can create a console command (read the guide about console application) that looks in this table and send the needed email.
With cron you can call this console command every 5 minutes.
Hi, Thanks for your comment.
Is it possible to access a console command after submersion of a form ? also to send parameters to console command ?
mazraara
(Mazraara)
September 27, 2012, 9:15am
11
[size=“3”][size=“4”]Can anybody help me pls, even if i go for a cron job i feel like it would’nt help me since i will execute the crone job in the same page as the last line.
even to run the cron job every 5 minutes, i must be able to pass values from my php class.
is there any way to pass parameters to console ?[/size][/size]
alex-w
(Pr0j3ct A1ex)
September 27, 2012, 9:28am
12
As above, Use Ajax.
Create each email in a separate ajax call.
e.g.
User Updates Profile -> Ajax request -> Email 1 sent -> Ajax request -> Emails 2 sent -> Ajax etc…
mazraara
(Mazraara)
September 27, 2012, 9:30am
13
[size=“3”]Yeah nah… ajax would be great at this point… tnx tnx [/size]
mazraara
(Mazraara)
September 27, 2012, 9:32am
14
[size=“3”]any easy way to send an ajax request for an action in yii ?? haven’t worked in ajax much.[/size]
zaccaria
(Matteo Falsitta)
September 27, 2012, 9:41am
15
about cron job, use a database table in which you save all parameters you should pass.
Every 5 minutes the console read the whole table (with the parameters), sends the needed mail and delete the corresponding lines.
As you see, you don’t have to pass parameters to the application.
You could just add a flag in the modified profile “should_mail_be_sent”, so you don’t need more table or any parameter, the command will read the marked records
mazraara
(Mazraara)
September 27, 2012, 9:43am
16
zaccaria:
about cron job, use a database table in which you save all parameters you should pass.
Every 5 minutes the console read the whole table (with the parameters), sends the needed mail and delete the corresponding lines.
As you see, you don’t have to pass parameters to the application.
You could just add a flag in the modified profile “should_mail_be_sent”, so you don’t need more table or any parameter, the command will read the marked records
Thanks for this as well. what do you think of ajax request ?? any idea to do with yii ??
mazraara
(Mazraara)
September 27, 2012, 9:49am
17
[size="4"]any idea to write an ajax call after model validates ?? or inside an action of a controller ?? [/size]
zaccaria
(Matteo Falsitta)
September 27, 2012, 9:51am
18
You are messing a lot, ajax is triggered from the browser, how you can trigger an ajax request inside an action?
mazraara
(Mazraara)
September 27, 2012, 9:53am
19
Yeah i agree with you zaccaria. i thought of it because a person recommended to have multiple ajax requests.
sorry.
mazraara
(Mazraara)
September 27, 2012, 9:54am
20
finally i am left with no choices other than a crone job.