4

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.

1
  • I've tagged your question with version 2009, since you commented that on the given answers, this way the answers can be catered towards that version (as most answers are assuming you are on 2011 or up). Commented Jul 24, 2013 at 7:04

4 Answers 4

9

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.

5
  • Many thanks for your reply, i will try this and will inform you for any help but this seems to be good approach for my case. Commented Jul 23, 2013 at 8:34
  • Could you please give some more hint on this, how and where to configure the config file? Commented Jul 23, 2013 at 8:35
  • You should read the Maintenance Guide. In short.... PurgeTool <XML file> /Purge should do it. Commented Jul 23, 2013 at 8:45
  • I have tried this and this can be a option to a certain extent, as i need to specify the dates in the config. I will suggest this but the requirement is to have something scheduled which will run on specific time period and do the clean up. thanks again. Commented Jul 23, 2013 at 12:18
  • this is probably your best bet indeed, you could script the creation of the config file so you can add specific dates in there and then schedule the script to run at a specific time (the script will create a config file and call the purge tool). Commented Jul 24, 2013 at 7:06
6

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.

3
  • Thanks for the response, is it will be possible to achieve usign some script which will be scheduled and do the automatic clean up? Will the clean up of "D\Tridion\transactions" folder solve the purpose? Commented Jul 23, 2013 at 7:07
  • At location "D\Tridion\transactions" which kind transactions are stored. I know about a transactions folder in location \Program Files (x86)\Tridion\bin\transactions which needed to be cleanup time to time. You can create bat file to do cleanup of this folder.
    – AlokBhatt
    Commented Jul 23, 2013 at 7:14
  • This is the same one("Tridion Home\transactions"), is it will solve the purpose of cleaing up the Pub queue items as well? Commented Jul 23, 2013 at 8:06
3

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.

1
  • Many thanks for the reply, if we clean the transaction folder resides in "TridionHome" directory, then will it solve the problem? We want to achieve this by using any scheduled job (script). Is it will be possible? Commented Jul 23, 2013 at 7:06
3

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

3
  • I am using 2009 version and application level code changes we can not do, we need to find out an external/stand alone script/program for this, please suggest. Commented Jul 23, 2013 at 8:08
  • Updated answer with Tom.Net code.
    – Syav4eg
    Commented Jul 23, 2013 at 8:21
  • I don't think that TOM.NET code will work on 2009, and anyways you should NEVER use it outside of a Template or the Event System, so creating a session like that and using it in an external program is not a correct use case. Since the OP is on 2009 he can use TOM in a VBScript or TOM interop in a .NET application. Commented Jul 24, 2013 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.