コード例 #1
0
        public async Task PublishAsync(IReadOnlyCollection <JournaledEvent> events)
        {
            Require.NotNull(events, "events");

            var       tryNumber = 1;
            Exception callException;

            do
            {
                try
                {
                    await m_streamWriter.AppendEventsAsync(events);

                    callException = null;
                }
                catch (EventStreamConcurrencyException exception)
                {
                    callException = exception;
                }

                if (callException != null)
                {
                    tryNumber++;
                    await m_streamWriter.MoveToEndOfStreamAsync();
                }
            }while (m_retryPolicy.AllowCall(tryNumber) && callException != null);

            if (callException != null)
            {
                throw callException;
            }
        }