As part of a CRM project, we integrated the functionality for the DiffMappings. For this purpose there is now the function LoadStatefulDocument, with whose help you can get the previous successfully processed version of the same document and then load it. In this context, you can no longer simply use the RemoveMessage JobStep should delete the old messages, but should do so in such a way that this is not only possible according to time, but also according to the last document instance. All in all, you may have to keep several thousand documents.
Note: To delete qualified documents in this scenario, use the JobStep StatefulDocumentMessageCollector to collect the messages in scope. Then connect it with the JobStep MessageDeletor and delete the old messages.
The rest is the same as for the MessageCollector
The function then collects the messages that contain exactly one document of the entity type. It then determines whether there are older documents of the same type with the same document number. It is sorted by EntryDate in descending order and as soon as the number of “documents to keep” with the same document number is reached, the older instances of the documents or messages are collected and loaded into the job as InputMessages. From there they can be deleted with the MessageDeletor or moved to another MessageBox etc.