0 votes
98 views
in Javascript API by (220 points)
Hello all,

I am using IBM BPM 7.5.2 version I have one observation while using participantGroups,

When user login time we fetch user role from LDAP using participantGroups.. This group having around 1500 users with different roles.

here i am sharing example

var myPG1= tw.system.org.findParticipantGroupByName("role1");

var allUsers = role1.allUsers;

for (var i=0; i<allUsers.length; i++)

{    log.info(allUsers[i].name);
}

for this approach it takes more than 2 mintues of time due to this performance got impacted.

Please suggest any better approach other than allUsers method to get length,name details.

2 Answers

0 votes
by (21.5k points)

I see that you have a typo in your code

var myPG1= tw.system.org.findParticipantGroupByName("role1");
myPG1.refresh();

var allUsers = myPG1.allUsers;

for (var i=0; i<allUsers.length; i++)

{    log.info(allUsers[i].name);
}

try a refresh once and time the individual steps which one is taking long time findPG or .allUsers also time the refresh also, idea being you may need to call refresh only once and caching should happen after that, I remember we had a situation where calling the refresh on a scheduled basis though a timer UCA helped.

0 votes
by (2.3k points)
My first question would be why you are doing this manually as group refresh is one of the actions that happens upon valid login of the user as part of the what the product simply does for you, so iterating over the users doesn't seem to server a purpose.

The second thing I would note is that due to the nature of the JS engine destructively processing large arrays shows significant performance gains over the use of iterators, assuming you don't need the array after processing is done.  So if you change your for loop to -

while(allUsers.length>0){

  log.info(allUsers[0].name);

  allUsers.delete(0);

}

for large arrays is will run faster.  (check the syntax though, can't remember if the exact call to remove an item from an array.

Related questions

0 votes
1 answer 25 views
0 votes
0 answers 309 views
0 votes
0 answers 30 views
0 votes
0 answers 70 views
0 votes
1 answer 47 views
0 votes
1 answer 66 views
0 votes
1 answer 240 views
0 votes
1 answer 34 views
0 votes
0 answers 17 views
0 votes
1 answer 29 views
0 votes
1 answer 39 views
...