Tuesday, January 12, 2016

Immediately send password reset notification e-mails

Configure WebSphere Commerce to immediately send password reset notification e-mails
When a user resets their password, by default the request is queued in the MSGSTORE table and the temporary password is not e-mailed to the customer until the SendTransactedMsg scheduled job is run.
To modify the behavior of the reset password notification logic, select one of the following solutions:
1. Increase the frequency of the SendTransactedMsg scheduled job, which sends out the temporary password notification e-mail. This might not be ideal as you might still experience some delay based on the frequency of the scheduled job.
You can modify the scheduled job's frequency by updating the Schedule interval value in the WebSphere Commerce Administration Console. 

2. Recommended: Leverage the sendImmediate () method within SendPasswordNotificationCmdImpl.performExecute() as SendPasswordNotificationCmdImpl makes use of the sendTransacted() method, which stores the reset password notification in the MSGSTORE table. For more information on the default behavior of SendPasswordNotificationCmdImpl, 

       SendMsgCmd sendMsgCmd = (SendMsgCmd)CommandFactory.createCommand(
                                "com.ibm.commerce.messaging.commands.SendMsgCmd", getStoreId());
                    sendMsgCmd.setMsgType("PasswordNotify");
                    sendMsgCmd.setStoreID(getStoreId());
                    TypedProperty tp = new TypedProperty();
                    tp.put("resetPasswordUrl", passwordNotifyMsg);
                    tp.put("LANGUAGE_ID", getCommandContext().getLanguageId());
                    sendMsgCmd.compose("NDFPasswordNotify", getCommandContext(), tp);
                    sendMsgCmd.sendImmediate();
                    sendMsgCmd.setCommandContext(getCommandContext());
                    sendMsgCmd.execute();


If you want the password reset notification e-mails to be sent to customers immediately after the request is made, you must extend and replace SendPasswordNotificationCmdImpl.performExecute() to use sendImmediate() rather than sendTransacted(). This sends the message directly to the customer instead of queuing it in the MSGSTORE table and waiting for the SendTransactedMsg job to run.

public void sendImmediate()
This method sends the message immediately to recipients. The caller is blocked until the message has been sent.

public void sendTransacted()

This method stores the message in the MSGSTORE database table. At a predetermined time, the WebSphere Commerce scheduler invokes a job that sends all messages stored in batch mode. Using this method ensures that a send occurs only after the caller has committed or terminated successfully. This method should be used if blocking a call using the sendImmediate() method cannot be tolerated.

No comments:

Post a Comment