6

I get an error when purging a large number of publishing transactions which indicates that there is a problem with the size of the received message size being greater than 10,485,760.

I have checked the TcmServiceHost.exe.config and the MaxReceivedMessageSize is configured to 2,147,483,647.

Anyone got ideas what the real problem is?

Sample Code:

$DaysToKeep = 120
[datetime]$dt = (Get-Date).AddDays(-$DaysToKeep) 
Import-Module Tridion.ContentManager.Automation
$transactions = Remove-TcmPublishTransactions -Before $dt
$purged=$transactions.count

More code to write purged transaction data to log file and notify change in Tridion Event log

Error:

Remove-TcmPublishTransactions : The maximum message size quota for 
incoming messages (10485760) has been exceeded. To increase the quota, 
use the MaxReceivedMessageSize property on the appropriate binding element.
At C:\scripts\PurgePublishingTransactions.ps1:58 char:17
+ $transactions = Remove-TcmPublishTransactions -Before $dt
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) 
[Remove-TcmPublishTransactions], CommunicationException
+ FullyQualifiedErrorId :
System.ServiceModel.CommunicationException,Tridion.ContentManager.Automation.Commands.RemoveTcmPublishTransactionsCommand

Configuration:

C:\Program Files (x86)\Tridion\bin\TcmServiceHost.exe.config

<netTcpBinding>
    <binding name="CoreService_netTcpBinding" 
      transactionFlow="true"
      transactionProtocol="WSAtomicTransaction11"
      maxReceivedMessageSize="2147483647">
      <readerQuotas 
       maxStringContentLength="2147483647"
       maxArrayLength="2147483647" 
       />                                           
    </binding>
    <binding name="StreamDownload_netTcpBinding"
      maxReceivedMessageSize="2147483647" 
      transferMode="StreamedResponse"
      sendTimeout="00:10:00" />
  </netTcpBinding>
1
  • In order for this to work you should have your limit set not only on the server side, but also on client side. If I'm not mistaken there was a way to increase it on this module. It was either command argument or config change. Otherwise just use another core client Commented Jun 5, 2015 at 15:32

3 Answers 3

3

I always try to use the supported code published by SDL. Since this code is supported, there will be less code to write, test and maintain myself.

SDL Have an enhancement request to fix Remove-TcmPublishTransactions -Before $dt

I the mean time I wrote a core service PowerShell script to get the transactions in a try catch block

    try
{
    #$transactions = Remove-TcmPublishTransactions -Before $dt 
    $filter = New-Object Tridion.ContentManager.CoreService.Client.PublishTransactionsFilterData
    $filter.StartDate = (Get-Date).AddDays(-1000)
    $filter.EndDate = (Get-Date).AddDays(-$DaysToKeep)
    $transactions = $core.GetSystemWideList($filter)
}

Catch and log to Windows Tridion Event log any failure

    catch
{
    $Exeption = $_.Exception.Message
    $Message = "Failed to Purge Publishing Transactions before $utcdate.$n $Exeption"
    Write-EventLog -LogName Tridion -eventID 100 -Source "Tridion Data" -EntryType Error -Category 0 -Message $Message 
    write-output $Message
    exit
}

Then looped through to remove them while logging the data to a csv file

    foreach($transaction in $transactions)
{
    $transactionID = $transaction.Id
    $Name = $transaction.Title
    $ItemId = $transaction.Items.IdRef
    $target = $transaction.ListInfo.PublicationTargetTitle
    $publication = $transaction.ListInfo.PublicationTitle
    $path = $transaction.ListInfo.ItemPath
    $action= $transaction.ListInfo.PublishAction
    $state =$transaction.State
    $Priority = $transaction.Priority
    $time = $transaction.StateChangeDateTime
    $User = $transaction.Creator.Title


    "$transactionID,$Name,$ItemId,$target,$publication,$path,$action,$state,$Priority,$time,$User" | Out-File $logfilename -NoClobber -Append -force
    #write-output "$transactionID,$Name,$ItemId,$target,$publication,$path,$action,$state,$Priority,$time,$User"

    $core.delete($transaction.Id)
}

The $filter.StartDate is set to a date before the system was first installed

Purging the Publishing Transactions is necessary but I like to keep the data for forensics when the client wants to know "who published that?" or "was this published early/late?"

2

Try using the Core Service client. I find the API very approachable andd the performance quite good. Will be quite easy to either write a console app or a Web GUI similar to the 2009 version.

Here's the sample code I have working in 2013 SP1:

string endpointName = "basicHttp_2013";
//string endpointName = "netTcp_2013";
string userName = ConfigurationManager.AppSettings["user"];
string password = ConfigurationManager.AppSettings["pw"];

using (CoreServiceClient client = new CoreServiceClient(endpointName))
{
    var credentials = CredentialCache.DefaultNetworkCredentials;
    if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password))
    {
        credentials = new NetworkCredential(userName, password);
    }
    client.ChannelFactory.Credentials.Windows.ClientCredential = credentials;


    PurgeOldVersionsInstructionData purgeIntructions = new PurgeOldVersionsInstructionData();

    // ** containers could probably be any folder, sg, or publication

    string folderUri = "tcm:11-172-2";
    LinkToIdentifiableObjectData folder = new LinkToIdentifiableObjectData();
    folder.IdRef = folderUri;
    purgeIntructions.Containers = new LinkToIdentifiableObjectData[] { folder };

    uint versionCount = 2;
    purgeIntructions.VersionsToKeep = versionCount;
    client.PurgeOldVersions(purgeIntructions);
}
1
  • Thanks Robert, I used core service in PowerShell to get the job done Commented Jun 11, 2015 at 10:19
-1

You probably have not purged in a while, therefore anything older than 120 days is probably a large number of records that exceeds the MaxReceivedMessageSize that the client has.

The solution is to do several runs of the script. For example:

  1. Execute the script with $DaysToKeep set to 1461, then
  2. execute the script with $DaysToKeep set to 1095, then
  3. execute the script with $DaysToKeep set to 730, then
  4. execute the script with $DaysToKeep set to 365, and finally
  5. execute the script with $DaysToKeep set to 120

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.