If we are using SendMsgCmd for triggering the email, the email will take 5 minutes delay, Because In WCS has message pool concept.When the SendMsgCmd is getting call it will send the msg into pool then the scheduler command SendTransactedMsg cmd will pick all the messages from Pool then send it to the appropriate account.
For avoiding that delay, We can use sendImmediate() method, but sometime this may cause the issue for thread hung. So if that is happened then we can't move out from the page. for avoid those kind of issue use the below logic.
1. In the SendMsgCmd use sendTransacted() then after that, call the SendTransactedMsg scheduler job immediately by using the below code.
For avoiding that delay, We can use sendImmediate() method, but sometime this may cause the issue for thread hung. So if that is happened then we can't move out from the page. for avoid those kind of issue use the below logic.
1. In the SendMsgCmd use sendTransacted() then after that, call the SendTransactedMsg scheduler job immediately by using the below code.
String strPasswordNotifyName = "PasswordNotify";
SendMsgCmd cmdSendMsg = (SendMsgCmd)CommandFactory.createCommand("com.ibm.commerce.messaging.commands.SendMsgCmd", getStoreId());
cmdSendMsg.setMsgType("PasswordNotify");
cmdSendMsg.setStoreID(getStoreId());
Messaging ms = new Messaging("PasswordNotify", getStoreId());
String strMsgSubjectKey = ms.getUserData(null, "subject_key");
String strSubject = buildMessageSubject(strMsgSubjectKey);
if(strSubject != null)
cmdSendMsg.setConfigData("subject", strSubject);
cmdSendMsg.addMember(getUsersId());
TypedProperty hshTypedProperty = new TypedProperty();
hshTypedProperty.put("logonId", getLogonId());
hshTypedProperty.put("logonPassword", getPassword());
CommandContext ccc = (CommandContext)getCommandContext().clone();
cmdSendMsg.compose(null, ccc, hshTypedProperty);
cmdSendMsg.sendTransacted();
cmdSendMsg.setCommandContext(ccc);
cmdSendMsg.setStoreID(ccc.getStoreId());
cmdSendMsg.execute();
LOGGER.logp(Level.INFO, CLASSNAME, methodName, "Message
parameters set for Password Reset email - Add job command being invoked");
AddJobCmd addJob = (AddJobCmd) CommandFactory.createCommand(AddJobCmd.NAME, getStoreId());
addJob.setCommandContext(getCommandContext());
addJob.setPathInfo("SendTransactedMsg");
addJob.setName("wcsadmin");
addJob.setStartTime(new Timestamp(System.currentTimeMillis()
+ 5));
addJob.setUrl("/");
addJob.setAccCheck(false);
addJob.execute();
LOGGER.logp(Level.INFO, CLASSNAME, methodName, " Add job
command being execution complete");
No comments:
Post a Comment