A request that I hear about sometimes is a way to purge messages or service instances in BizTalk. The usual response is to refer people to the built-in SQL jobs for purging the DTA archive or the MessageBox databases. These are excellent parts of a well-designed BizTalk database maintenance plan. But sometimes you see service instances or suspended messages that are still stuck in the BizTalk infrastructure. You can execute all of these maintenance jobs but none of them seem to get the stuck messages. I was in this situation today and I went through all of the maintenance plan jobs but none of them seemed to resolve the stuck messages and service instances. The statistics screen called the BizTalk Group hub page continued to show old suspended messages and service instances. I was investigating the suspended messages and found a way of actually removing these items without using the database jobs.
If you click on a link on the group hub page, it will show the results of a query run against the suspended messages, service instances, or other artifacts of the BizTalk system. I clicked on a link for the suspended service instances and then looked down in the search results. When I right-clicked on the search results, I found an item for “Terminate Instance”. This actually removed the suspended item from the BizTalk infrastructure. The screenshot below shows how this would look in the BizTalk admin console:
This technique actually works for multiple item removals as well. It is possible to multi-select the search result items and then right click on them as well. This can be a really helpful way of removing suspended service instances and messages. This is by far the easiest way to selectively purge service instances and messages and does not require connecting to SQL Server either.