AIF Document History With Many Records
An issue was surfaced recently by one of our partners about how to handle the AIF Document History form when there's a large volume of messages being exchanged. For example, if you have an installation that's sending say, 20,000 messages a day, the Document History tables fill up fast.
First, a little information about what ends up in the Document History. When you send or receive a message asynchronously, it ends up in the gateway queue within Dynamics AX. In asynchronous exchanges, you would be using one of the adapters, like the file system adapter. After the message leaves the gateway queue, whether that message is coming into AIF or leaving AIF, it's recorded in the Document History *if* you have set Logging to Log All or Log Original.
To digress for a moment, the type of logging you want is set per endpoint, per action in the Basic > Setup > Application Integration Framework > Endpoints > Action policies form. Needless to say, you want to enable logging so that you can track what's happening with messages in AIF.
The document history records are found in the AifDocumentLog and AifMessageLog tables and are displayed depending on how you toggle the Display by combo box on the Document History form (AifDocumentHistory in the AOT).
Within the Document History form you can delete records in the grid by selecting a record and clicking the delete toolbar button. You can only delete records that have a status of Processed or Error as defined in the AifMessageStatus enum (this code is in the adjustGUI form method). Deleting the messages manually in the Document History form is doable because you can multi-select and delete.
But if that isn't feasible for your implementation, the best option is to create an X++ job to delete the records from these tables using the standard procedure to delete records from a table. Once you create this job, you could put a button on the Document History form and call it from the click event or you could set the job to run as a scheduled batch. You could get fancy and allow users to only delete records that have successfully processed so that records with errors are deleted in batch mode.
Hope this provides some insight if you're encountering this issue in AIF.