1 Reply Latest reply on Oct 5, 2009 6:15 PM by Ronald van Kuijk

    Starting process instance by key

    henry donnell Newbie

      Today in a project we are currently doing, I was suprised to find out that startProcessInstanceByKey(procDefId, key) allows to use the same key many times. Although it is clear that this is intended to be a business key,
      I still wonder why it is not forced to be unique.

      I actually planned to use this key as some sort of locking mechanism to lock the business object used by a process against being used in another process instance. Thus if I'd start another process instance with the same key whilst the previous one is running, I'd expect to get an exception.

      Now, the only work around seems to be to check before starting a new process instance, if another process instance is running with the same key and not allow to start the new instance until the previous one is finished.

      Does anyone have a better idea?

        • 1. Re: Starting process instance by key
          Ronald van Kuijk Master

          According to the docs it *should* be unique, so in that case the only thing missing according to you is a unique constraint on the database.

          Personally, I make the key unique myself by using it in a 'compound' way. I used a license plate number, followed by a colon and a date (assuming two insurance claims were not started on the same day). In other demo I used the insurance claim number for the businesskey, making it unique in that way and prevent duplicates. I've not run into a problem with this, but it might not hurt to add a unique constraint. Please file a jira issue for this, though I'm not 100% sure what the outcome might be. You could discuss this on the dev list first.