Sitecore Messagingライブラリは、接続エラーが発生した場合にSQL データベースへの接続を再試行するように構成できます。Sitecore.Framework.TransientFaultHandlingライブラリは、再試行機能を提供するために使用されます。 接続の再試行の動作を使用するようにMessagingを構成するには、次の手順を実施する必要があります。
次の例では、データベースへの接続を 10 回再試行した後に失敗する指数リトライヤーを定義しています。
DefaultSqlPolicyRetryerFactoryは、デフォルトでSQL Always OnおよびSQL Azureの一時的なエラーを処理できるリトライヤーを作成します。 CustomErrorCodesセクションの下に、追加のエラー コードを追加できます:
<Settings>
<Sitecore>
<XConnect>
<Services>
<TransientFaultHandling>
<Type>Sitecore.Framework.TransientFaultHandling.RetryerRegistry, Sitecore.Framework.TransientFaultHandling</Type>
<As>Sitecore.Framework.TransientFaultHandling.IRetryerRegistry, Sitecore.Framework.TransientFaultHandling.Abstractions</As>
<Options>
<Retryers>
<Messaging.ExponentialRetryer>
<Type>Sitecore.Framework.TransientFaultHandling.Sql.DefaultSqlPolicyRetryerFactory, Sitecore.Framework.TransientFaultHandling.Sql</Type>
<Options>
<CustomErrorCodes>
<ConnectionError>19</ConnectionError>
</CustomErrorCodes>
<ExponentialRetry>
<MaxAttempts>10</MaxAttempts>
<MinBackoff>00:00:01</MinBackoff>
<MaxBackoff>00:00:30</MaxBackoff>
<DeltaBackoff>00:00:10</DeltaBackoff>
</ExponentialRetry>
</Options>
</Messaging.ExponentialRetryer>
</Retryers>
</Options>
</TransientFaultHandling>
</Services>
</XConnect>
</Sitecore>
</Settings>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<TransientFaultHandling>
<Retryers>
<Messaging.ExponentialRetryer>
<Type>Sitecore.Framework.TransientFaultHandling.Sql.DefaultSqlPolicyRetryerFactory, Sitecore.Framework.TransientFaultHandling.Sql</Type>
<Options>
<CustomErrorCodes>
<ConnectionError>19</ConnectionError>
</CustomErrorCodes>
<ExponentialRetry>
<MaxAttempts>10</MaxAttempts>
<MinBackoff>00:00:01</MinBackoff>
<MaxBackoff>00:00:30</MaxBackoff>
<DeltaBackoff>00:00:10</DeltaBackoff>
</ExponentialRetry>
</Options>
</Messaging.ExponentialRetryer>
</Retryers>
</TransientFaultHandling>
</sitecore>
</configuration>
<Settings>
<Sitecore>
<Processing>
<Services>
<RetryerRegistry>
<Options>
<Retryers>
<ExponentialRetryer>
<Type>Sitecore.Framework.TransientFaultHandling.Sql.DefaultSqlPolicyRetryerFactory, Sitecore.Framework.TransientFaultHandling.Sql</Type>
<Options>
<CustomErrorCodes>
<ConnectionError>19</ConnectionError>
</CustomErrorCodes>
<ExponentialRetry>
<MaxAttempts>10</MaxAttempts>
<MinBackoff>00:00:01</MinBackoff>
<MaxBackoff>00:00:30</MaxBackoff>
<DeltaBackoff>00:00:10</DeltaBackoff>
</ExponentialRetry>
</Options>
</ExponentialRetryer>
</Retryers>
</Options>
</RetryerRegistry>
</Services>
</Processing>
</Sitecore>
</Settings>
Messaging BusがTransientFaultHandlingリトライヤーを使用するように構成するには、Messagingトランスポートの構成でリトライヤーを明示的に指定する必要があります。これは、次の構成を使用して実施できます:
<Sitecore.Processing.Engine.Buses.TaskProgressConsumer>
<Transport>
<SqlServer>
<OneWay>false</OneWay>
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<TableName>Sitecore_Transport</TableName>
<InputQueueName>SitecoreProcessingTaskProgressConsumer</InputQueueName>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Transport>
<Logging Type="Sitecore.Framework.Messaging.Rebus.DotNetLoggerFactory, Sitecore.Framework.Messaging.Rebus" />
</Sitecore.Processing.Engine.Buses.TaskProgressConsumer>
<Sitecore.Processing.Engine.Buses.TaskRegistrationConsumer>
<Transport>
<SqlServer>
<OneWay>false</OneWay>
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<TableName>Sitecore_Transport</TableName>
<InputQueueName>SitecoreProcessingTaskRegistrationConsumer</InputQueueName>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Transport>
<Logging Type="Sitecore.Framework.Messaging.Rebus.DotNetLoggerFactory, Sitecore.Framework.Messaging.Rebus" />
</Sitecore.Processing.Engine.Buses.TaskRegistrationConsumer>
<Sitecore.Processing.Engine.Abstractions.Buses.TaskStatusBus>
<Transport>
<SqlServer>
<OneWay>false</OneWay>
<!--Set of credentials for proper connection to database-->
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<!--The name of the table which holds messages until they are handled-->
<TableName>Sitecore_Transport</TableName>
<!--The name of MSMQ queue which publisher uses for publishing message to the bus-->
<InputQueueName>TaskStatus</InputQueueName>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Transport>
<Subscriptions>
<SqlServer>
<!--Set of credentials for proper connection to database-->
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<!--The name of the table which saves the information about the relationships between queues and messages-->
<TableName>Sitecore_Subscriptions</TableName>
<!--Means that both subscribers and publishers have access to the same central subscription storage-->
<IsCentralized>true</IsCentralized>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Subscriptions>
<Logging Type="Sitecore.Framework.Messaging.Rebus.DotNetLoggerFactory, Sitecore.Framework.Messaging.Rebus" />
</Sitecore.Processing.Engine.Abstractions.Buses.TaskStatusBus>
<Sitecore.Processing.Tasks.Messaging.Buses.TaskRegistrationProducer>
<Transport>
<SqlServer>
<OneWay>false</OneWay>
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<TableName>Sitecore_Transport</TableName>
<!-- InputQueueName should be unique for CM/CD instance to handle response messages on the correct instance. -->
<InputQueueName>SitecoreProcessingTaskRegistrationProducer_${MachineName}_${ProcessId}</InputQueueName>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Transport>
<Routing>
<TypeBasedMappings>
<TypeMappings>
<RegisterDistributedTaskMap>
<Type>Sitecore.Processing.Engine.Abstractions.Messages.RegisterDistributedTask, Sitecore.Processing.Engine.Abstractions</Type>
<DestinationQueue>SitecoreProcessingTaskRegistrationConsumer</DestinationQueue>
</RegisterDistributedTaskMap>
<RegisterDeferredTaskMap>
<Type>Sitecore.Processing.Engine.Abstractions.Messages.RegisterDeferredTask, Sitecore.Processing.Engine.Abstractions</Type>
<DestinationQueue>SitecoreProcessingTaskRegistrationConsumer</DestinationQueue>
</RegisterDeferredTaskMap>
</TypeMappings>
</TypeBasedMappings>
</Routing>
<Logging Type="Sitecore.Messaging.SitecoreLoggerFactory,Sitecore.Messaging"/>
</Sitecore.Processing.Tasks.Messaging.Buses.TaskRegistrationProducer>
リトライヤーを使用するようにEXMを構成するには、対応するサーバーのSitecore.EmailExperience.Messaging.configファイルを更新する必要があります。
例:
<Sitecore.EmailCampaign.Model.Messaging.Buses.UpdateListSubscriptionMessagesBus role:require="!DedicatedDispatch">
<Transport>
<SqlServer>
<OneWay role:require="(Standalone or ContentManagement) and !ContentDelivery">false</OneWay>
<OneWay role:require="ContentDelivery">true</OneWay>
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<TableName>Sitecore_Transport</TableName>
<InputQueueName>UpdateListSubscriptionMessagesQueue</InputQueueName>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Transport>
</Sitecore.EmailCampaign.Model.Messaging.Buses.UpdateListSubscriptionMessagesBus>
例:
<Sitecore.EmailCampaign.Model.Messaging.Buses.AutomatedMessagesBus>
<Transport>
<SqlServer>
<OneWay>true</OneWay>
<ConnectionStringOrName>messaging</ConnectionStringOrName>
<TableName>Sitecore_Transport</TableName>
<InputQueueName>AutomatedMessagesQueue</InputQueueName>
<RetryerName>ExponentialRetryer</RetryerName>
</SqlServer>
</Transport>
<Sitecore.EmailCampaign.Model.Messaging.Buses.AutomatedMessagesBus>