問題のコンテキスト: NServiceBus メッセージ ハンドラーで RavenDB に新しいドキュメントを追加しようとしているコードがあります。
コード:
partial void HandleImplementation(SomeMessage message)
{
PutDataIntoCache(message.CacheKey, message.Document);
}
void PutDataIntoCache(string key, Document document)
{
using (var documentStore = new DocumentStore { Url = "http://localhost:8084" })
{
documentStore.Initialize();
using (IDocumentSession session = documentStore.OpenSession())
{
using (var tx = new TransactionScope())
{
session.Store(document, key);
session.SaveChanges();
tx.Complete();
}
}
}
}
エラー
I'm getting the following error:
Raven.Abstractions.Exceptions.ConcurrencyException: A document with key: 'cache-fncwr10b' is currently created in another transaction
at Raven.Client.Connection.ServerClient.DirectBatch(IEnumerable`1 commandDatas, String operationUrl) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\ServerClient.cs:line 863
at Raven.Client.Connection.ServerClient.<>c__DisplayClass56.<Batch>b__55(String u) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\ServerClient.cs:line 837
at Raven.Client.Connection.ServerClient.TryOperation[T](Func`2 operation, String operationUrl, Boolean avoidThrowing, T& result) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\ServerClient.cs:line 222
at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func`2 operation) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\ServerClient.cs:line 192
at Raven.Client.Connection.ServerClient.Batch(IEnumerable`1 commandDatas) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\ServerClient.cs:line 837
at Raven.Client.Document.DocumentSession.SaveChanges() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentSession.cs:line 441
at CacheWarmer.Listener.Caching.UpdateCacheEntryProcessor.PutDataIntoCache(String key, ConfgDataModel confgDataModel) in UpdateCacheEntryProcessor.cs
質問 これに出くわした人はいますか? どのように解決しましたか?何が原因でしょうか?
役立つコメントやヒントをいただければ幸いです。