Sending mail Via Plain java API taking time to save Workitem ?
Hi All,
Hope all are doing well. My question is about Performance issue while sending email at state change. In one of the server side plugin we are sending email to all the members in the team area and for state.
Once we are doing workitem operation and change the the state that time email sending is taking to much time to even there are only two members in team area.
So what could be the problem in this approach. I am unable to get the actual reason behind this problem.
Please give us your suggestion on it. so that will reduce the performance overhead isue in our plug-in.
Accepted answer
Hi Sayo,
ok, that makes perfect sense.
Without looking at your code here are a couple of questions that might guide in the investigation: what exactly is "taking too much time"? A particular method in your code, the actual time between saving the work item and receiving the email or anything else? What time do you expect and what time do you measure?
Does it behave the same in test environment and staging / production? If you cannot debug your code at runtime you might want to put logging statements in there with output of a timer to gauge where the performance hit might be.
Other than that I highly recommend to at the very least update your 5.0.1 environment to 5.0.2 ifix26 for stability and support reasons.
- Arne
2 other answers
Hi Arne,
Thanks for quick reply.
Actually In our logic we are sending the email once we change the state of Workitem. so In that case If suppose i change the workitem state then its taking time to save workitem.
Here is the code:
public void automaticemailtoFPMContentTeam(IWorkItem workingCopy1,
IMailerService mailService, IWorkItemServer wis,
IWorkItemCommon wiCommon, IParticipantInfoCollector collector) {
// TODO Auto-generated method stub
try
{
IWorkItem workingCopy = (IWorkItem) wis.getAuditableCommon().resolveAuditable(workingCopy1, IWorkItem.FULL_PROFILE,null).getWorkingCopy();
IProjectAreaHandle iProjectAreaHandle = workingCopy.getProjectArea();
IProjectArea iProjectArea=(IProjectArea)wis.getAuditableCommon().resolveAuditable(iProjectAreaHandle, ItemProfile.PROJECT_AREA_DEFAULT, null);
String emailsubject=null;
String emailBody=null;
IAttribute attribute_packstatus=wis.findAttribute(workingCopy.getProjectArea(), "PackStatus", null);
IEnumeration packstatusenum1 =wis.resolveEnumeration(attribute_packstatus, null);
Identifier<? extends ILiteral> iliteral_packstatus= (Identifier<? extends ILiteral>) workingCopy.getValue(attribute_packstatus);
List literal_all = packstatusenum1.getEnumerationLiterals();
String PackStatus = null;
for (Iterator iterator = literal_all.iterator(); iterator.hasNext();)
{
ILiteral iLiteral = (ILiteral) iterator.next();
if (iLiteral.getIdentifier2().equals(iliteral_packstatus))
{
PackStatus = iLiteral.getName();
//System.out.println("its value is "+displayvalue);
}
}
emailsubject="Frontend Pack Master state Change Notification";
IContributorHandle Ownedbyhandle=workingCopy.getOwner();
IContributor contributor = (IContributor)wis.getAuditableCommon().resolveAuditable(Ownedbyhandle, ItemProfile.CONTRIBUTOR_DEFAULT, null);
String projectarea11=iProjectArea.getName();
String projarea=projectarea11.replaceAll(" ", "");
// System.out.println(projarea);
long datecur= System.currentTimeMillis();
Timestamp mdate = new Timestamp(datecur);
emailBody = "A new workitem pack (Task):"+workingCopy.getHTMLSummary().getPlainText()";
List<ICategory> findCategories=wis.findCategories(iProjectAreaHandle, ICategory.FULL_PROFILE, null);
for (ICategory category11 : findCategories) {
ICategory catttt=category11;
// System.out.println(catttt);
String catname = catttt.getName();
// System.out.println(catname);
if(catname.equalsIgnoreCase("Pending with EMS") || catname.equalsIgnoreCase("Pending with Dev") ||catname.equalsIgnoreCase("Pending with "))
{
List<ITeamAreaHandle> allteamareas=catttt.getAssociatedTeamAreas();
for(ITeamAreaHandle teamAreaHandle : allteamareas)
{
ITeamArea allteamarea11=(ITeamArea) wis.getAuditableCommon().resolveAuditable(teamAreaHandle, ItemProfile.TEAM_AREA_DEFAULT, null);
// System.out.println(allteamarea11);
IContributorHandle[] teammembers1=allteamarea11.getMembers();
// System.out.println(teammembers1);
for(IContributorHandle memberHandle : teammembers1)
{
IContributor teamMember= (IContributor)wis.getAuditableCommon().resolveAuditable(memberHandle, ItemProfile.CONTRIBUTOR_DEFAULT, null);
String mailAddress = teamMember.getEmailAddress();
//System.out.println(mailAddress1);
mailService.sendMail(mailService.getDefaultSender(), mailAddress,emailsubject, emailBody ,null);
}
}
Hi,
Why are you writing a server side plugin for functionality which is there out of the box?
That aside, without looking at your code it will be nigh impossible to remark on its performance.
- Arne
Comments
Hi Arne,
Thanks for your reply. I know there is out of box functionality. but user want to send the email to only to specific team and with specific mail body so that we have written follow up action. and in code we are just fetching the filed against value and depending on filed against value we are fetching the team members. RTC version is 5.0.1
Hi Arne,
Thanks for quick reply.
Actually In our logic we are sending the email once we change the state of Workitem. so In that case If suppose i change the workitem state then its taking time to save workitem.
Please find code as below