Blueriq Case Modelling has an inbox pattern that ensures that messages are processed only once. When messages are processed by multiple runtimes, or the queue from which the messages are read have multiple consumer threads, the following errors can occur in the log:


2024-02-20 13:55:41.854 INFO  c.b.s.messaging.service.BaseInboxService httpSessionId="" runtimeSessionId="" userId="" projectName="" projectVersion="" currentPageName="" [trace=65d4a14d4ff8a1dee9bb69aa446b27f1,span=b3d4933f4af22fc6] - timeline message not yet in inbox: d64a53b4-a717-4b1d-baed-09f0957183a7
2024-02-20 13:55:41.857 WARN    o.h.engine.jdbc.spi.SqlExceptionHelper httpSessionId="" runtimeSessionId="" userId="" projectName="" projectVersion="" currentPageName="" [trace=65d4a14d4ff8a1dee9bb69aa446b27f1,span=b3d4933f4af22fc6] - SQL Error: 2627, SQLState: 23000
2024-02-20 13:55:41.857 ERROR   o.h.engine.jdbc.spi.SqlExceptionHelper httpSessionId="" runtimeSessionId="" userId="" projectName="" projectVersion="" currentPageName="" [trace=65d4a14d4ff8a1dee9bb69aa446b27f1,span=b3d4933f4af22fc6] - Violation of PRIMARY KEY constraint 'pk_timeline_inbox'. Cannot insert duplicate key in object 'dbo.timeline_inbox'. The duplicate key value is (d64a53b4-a717-4b1d-baed-09f0957183a7).


The reason is that the same message (with identical message id) is processed by two different threads (consumer threads or different runtimes) at exactly the same time. Then when the message id is inserted in the database, one of the threads will fail as the message id can only be inserted once (which is the purpose of the inbox pattern).

Although this is logged as a warning and an error, this is expected behavior and nothing goes wrong. The thread that fails with this error will be retried later and then the message will be simply discarded because it is already processed.

So, in this specific case, the logging above can be ignored.