Skip to main content

Hi All,


This is the errror I am getting :


"Item has already been added. Key in dictionary: '2180'  Key being added: '2180'"


I am using 2 processes where one process calls another process thru IPC.


The process which calls has 3 activities and in the last activity IPC call is implemented. I am getting the error in the called process. 


Let's say I have 2 processes A and B .


A calls B .


I am getting error in B. B has the start activity follwed by a server event . First I got an error in the line connecting start activity with the activity that has the server event.


Subsequently , I got error in the server event.


The crunch is here : "Sometimes I get error and sometimes I do not".


The value 2180 is getting updated with error also.


 


Pls help me out of this mire.


Thanks and Regards

Hi,


There's a hotfix available for this problem on the customer and partner portal.  Please refer to Hotfix 2 on the following page:


https://portal.k2workflow.com/downloads/sets/hotfixes.aspx?pid=2


Best regards,


Ockert


Hi ockert,

Hi ockert,


Thanks for replying.


Can U suggest any other way to do it ? Cause I do not have access to portal.k2workflow.com.


Hi,


Is the error coming because of the fact while executing the process , K2 Server is trying to add some code in the dictionary.


Pls clarify the above query.


 


Hi sourcecode.


The hotfix that Ockert referred to addresses this known issue within K2.  I had encountered this situation before the hotfix and the only work around was to do a Sleep (via .NET code) for a certain period of time (I think i used 1 second).  This provided enough time to pass for K2 to create a new unique key in the internal dictionary.  Unfortunately this was quite a while ago, so I don't remember exactly where I put the Sleep().  I did it either at the end of the IPC call or in a Server Event following the IPC event.  If you choose to go this route, you will need to experiment a bit to find the correct location and duration. 


Also keep in mind that this should really be viewed as a last-case workaround as it is never usually a great idea to Sleep() as it can slow down overall K2 performance, especially in a high volume environment.  The situation I used this technique in was concept based development, so performance was not a significant consideration at that point in the development process and once the hotfix was available I applied it and removed my sleep().


HTH.


Hi Bob,


Lots of thanks for replying.


U are suggesting to use Sleep method either in an IPC event or in a server event. But as per my knowledge , We cannot use it in either of them cause Sleep is a method of WorkListItem class and in IPC event  a reference to "IPCEventContext" class is passed as parameter and to a server event an object of class "ServerEventContext" is passed as parameter.


Shall I use Sleep() in .NET or in K2 code ?


Pls clarify and forgive me if I am wrong .


I was referring to .NET Sleep. I believe somewhere within System.Threading namespace.

Hi Bob,


Thanks a lot for replying.


I will definitely try it but where to write it ? In .NET editor or in code editor provided by K2 studio.


This will need to happen in the K2.net Studio code.


Hi Bob,


Thanks a lot for replying.


As per my knowledge in K2 , I will have to take System.Threading as refernce and then using an object of Thread class I will call sleep().


Pls clarify whether I am right or not or pls  suggest a way to do so.


 


You should be able to call the Sleep method as follows (in C#) with no additional project level configuration:


    System.Threading.Thread.Sleep(1000);


 


Hi Bob,


Thanks a lot for replying.


Hi All,


Consider the following situation:


I have 2 K2 processes. One process (A) is calling another(B). Call is synchronous. A has a server event which uses .NET code to call the Bussiness Layer(BL). The BL has one function that calls a SP written in ORACLE. The SP writtens a varchar2 to the function. The function in BL returns a string. That string is stored in a K2 Process Datafield of A. Then the datafield is splitted(using String.split()) and one by one a value is passed to B. B's first activity is a server event which implements a function of the same BL.


 This is the scenario where I get the error : "Item has already been added. Key in dictionary: '2605'  Key being added: '2605'" .


I would like to add one more thing. I get the error whenever I export A nd B for the first time. On subsequent exports I do not encounter the error.


Can anyone pls tell as to why this error is coming? Pls reply ASAP.


I'm not really sure why the Oracle SP would impact this. 


Have you installed the hotfix requested by Ockert yet?  If not, have you tried implementing the Sleep workaround? 


When you say exports, do you mean that when you export both processes, the next time they are requested you see this, but the times after that there are no issues.  But if you then re-export both, you encounter it again the first time through?


Hi Bob,


Thanks a lot for replying.


Please correct me if I am mistaken.


Actually , I have not installed the Hotfix. But I tried the sleep workaround as U have suggested. It worked. Actually I wanted to know why the error is coming ?


By saying exports, I mean I am exporting both the processes. And the first time I export both , I get the error i.e., with Version No.1 but with subsequent exports of both processes or even one , I do not get the error.


Mainly , I wanted to know , why the error is coming?


 


As for what the actual error is; I don't know as it was internal to the product, but as stated earlier this was corrected within the hotfix mentioned here.


In terms of why this is occuring after a re-export I suspect that this is because of the re-compile required the first time a newly exported process is used.  It may be interesting to bump your sleep time to see if there is a difference.


That being said, the hotfix is definately the bets option as increasing Sleep()'s can have performance implications.


Hi Bob,


I got the hotfix required but what shall I do with that ?


Please guide


Thanks and Regards


Reply