Is there any way, the publishing queue clean up can be done automatically? Not by use of Purge Tool, by using any .bat or other script?
Please share your valuable comments on this.
Thanks in advance.
Is there any way, the publishing queue clean up can be done automatically? Not by use of Purge Tool, by using any .bat or other script?
Please share your valuable comments on this.
Thanks in advance.
You can use the purge tool for this. From the file menu, you can save a configuration file, and then to run the tool in batch mode, pass the path to this file on the command line.
PurgeTool <XML file> /Purge
should do it.
Commented
Jul 23, 2013 at 8:45
To delete Failed transactions you can use the below code.
public void DeleteItemsFromPublishingQueue()
{
using (var m_Client = GetCoreServiceClient())
{
List<string> transactionsToDelete = new List<string>();
PublishTransactionsFilterData filter = new PublishTransactionsFilterData
{
PublishTransactionState=PublishTransactionState.Failed,
StartDate = DateTime.Now.AddHours(-2),
PublicationTarget = new LinkToPublicationTargetData { IdRef = "tcm:0-1-65537" }
};
foreach (PublishTransactionData transaction in m_Client.GetSystemWideList(filter))
{
transactionsToDelete.Add(transaction.Id);
}
foreach (string transactionId in transactionsToDelete)
{
m_Client.Delete(transactionId);
}
}
}
You can create an application which can run on frequent intervals or manually on your wish. In this application you can code as above. In this code you can set different filters and clean up your publishing queue.
Publish Transactions can be clean up through the APIs/Core Service. You can decide for yourself what publish transactions to remove from the list. My approach would be:
1) create a list of publish transactions based upon a set of criteria (e.g. from date A to date B or success / failure) 2) cycle that list deleting the items and optionally check further conditions that might include/exclude an transaction from being deleted.
What Tridion version do you use ?In Tridion 2013 there are PowerShell scripts for this. Tridion 7 (2011) SP1 and higher has CoreService method PurgeQueue for purging specific queue (not only publish) - so you can use your application with next code :
using (var client = new SessionAwareCoreServiceClient())
{
client.PurgeQueue(1);
}
(1 is number of publish queue. All values you can find in the table dbo.QUEUES)
Edited... You can try to use Tom.Net for this as well - this was added in 2009 (honestly don't know - is it in your release verion or not).
using (Session session = new Session(@"Your User"))
{
QueuingEngine engine = new QueuingEngine();
engine.PurgeQueue(1);
}
For using QueuingEngine you must make reference to Tridion.ContentManager.Queueing