cancel
Showing results for 
Search instead for 
Did you mean: 

Buisnesskey duplicate possible

billdoor
Champ in-the-making
Champ in-the-making
long story short, while testing a class that starts Processes, i ran into unexpected results while trying to start the same Process twice with the same Businesskey:


@Test (expected = IllegalArgumentException.class)
    @Deployment(resources  = {"test_process.bpmn"})
    public void startProcess_duplicateBkey() {
        rule.getRuntimeService().startProcessInstanceByKey("test_process", "a1");
        rule.getRuntimeService().startProcessInstanceByKey("test_process", "a1");
        System.out.println(rule.getRuntimeService().createProcessInstanceQuery().processInstanceBusinessKey("a1", "test_process").list().size());
    }


prints "2".

I thus have two instances of "test_process" with businesskey "a1". In my understanding, this should not be possible, should it?
4 REPLIES 4

martin_grofcik
Confirmed Champ
Confirmed Champ
There was an discussion about it and from some activiti release (I can not remember which one) business key unique constraint was removed.

Regards
Martin

trademak
Star Contributor
Star Contributor
Martin is correct, we removed the constraint in 5.15 or 5.16 I think. If you want it to be unique, you could query on it before starting a new process instance, but there are also use cases where duplicates are necessary.

Best regards,

billdoor
Champ in-the-making
Champ in-the-making
Yea i found the discussion. Besides the sideffect on the historytable i thought of the constraint as good. But this was talked over so thanks for the answer, i'll just have to query then

jbarrez
Star Contributor
Star Contributor
Or add the constraint yourself