public void BufferAfterClosedEnqueueThrows() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Close(); queue.SetError(new Exception()); Assert.Throws<InvalidOperationException>(() => queue.Enqueue(_ => TaskAsyncHelper.Empty, null)); }
public void CloseWhileQueueRuns() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Open(); queue.Enqueue(_ => Task.Delay(50), null); queue.Enqueue(_ => Task.Delay(100), null); queue.Enqueue(_ => Task.Delay(150), null); queue.Close(); }
public void EnqueueWithoutOpenRaisesOnError() { var tcs = new TaskCompletionSource<object>(); var config = new ScaleoutConfiguration() { RetryOnError = true, OnError = ex => tcs.SetException(ex) }; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", config); queue.Enqueue(_ => { throw new InvalidOperationException(); }, null); Assert.Throws<AggregateException>(() => tcs.Task.Wait()); }
public ScaleoutStreamManager(Func <int, IList <Message>, Task> send, Action <int, ulong, IList <Message> > receive, int streamCount, ScaleoutConfiguration configuration, TraceSource trace) { _sendQueues = new ScaleoutTaskQueue[streamCount]; _send = send; _receive = receive; var receiveMapping = new ScaleoutMappingStore[streamCount]; for (int i = 0; i < streamCount; i++) { _sendQueues[i] = new ScaleoutTaskQueue(trace, "Stream(" + i + ")", configuration); receiveMapping[i] = new ScaleoutMappingStore(); } Streams = new ReadOnlyCollection <ScaleoutMappingStore>(receiveMapping); }
public ScaleoutStreamManager(Func<int, IList<Message>, Task> send, Action<int, ulong, IList<Message>> receive, int streamCount, ScaleoutConfiguration configuration, TraceSource trace) { _sendQueues = new ScaleoutTaskQueue[streamCount]; _send = send; _receive = receive; var receiveMapping = new ScaleoutMappingStore[streamCount]; for (int i = 0; i < streamCount; i++) { _sendQueues[i] = new ScaleoutTaskQueue(trace, "Stream(" + i + ")", configuration); receiveMapping[i] = new ScaleoutMappingStore(); } Streams = new ReadOnlyCollection<ScaleoutMappingStore>(receiveMapping); }
public void ErrorOnSendBuffers() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Open(); queue.Enqueue(_ => { throw new InvalidOperationException(); }, null); queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); Assert.Equal(0, x); }
public void InitialToBufferingToOpenToSend() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.SetError(new Exception()); queue.Open(); queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null).Wait(); Assert.Equal(1, x); }
public void ErrorOnSendThrowsNextTime() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration()); queue.Open(); queue.Enqueue(_ => { throw new InvalidOperationException(); }, null); Assert.Throws<InvalidOperationException>(() => queue.Enqueue(_ => TaskAsyncHelper.Empty, null)); }
public void EnqueueWithoutOpenThrows() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration()); Assert.Throws<InvalidOperationException>(() => queue.Enqueue(_ => { throw new InvalidOperationException(); }, null)); }
public void ThrowingFromErrorCallbackIsCaught() { var config = new ScaleoutConfiguration() { RetryOnError = true, OnError = ex => { throw new Exception(); } }; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", config); queue.SetError(new Exception()); }
public void SendsDuringInitialThenBufferingShouldNotSend() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); Task task = queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); queue.SetError(new Exception()); task.Wait(TimeSpan.FromSeconds(0.5)); Assert.Equal(0, x); }
public void SendsBeforeBufferingShouldBeCaptured() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); queue.SetError(new Exception()); Task task = queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); queue.Open(); task.Wait(); Assert.Equal(2, x); }
public void SendAfterCloseThenOpenRemainsClosed() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Open(); queue.Enqueue(_ => Task.Delay(50), null); queue.Close(); queue.Open(); Assert.Throws<InvalidOperationException>(() => queue.Enqueue(_ => TaskAsyncHelper.Empty, null)); }
public void OpenAfterErrorRunsQueue() { int x = 0; var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Open(); queue.Enqueue(_ => { throw new InvalidOperationException(); }, null); queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); var task = queue.Enqueue(_ => { x++; return TaskAsyncHelper.Empty; }, null); queue.Open(); task.Wait(); Assert.Equal(2, x); }
public void InitialToClosed() { var queue = new ScaleoutTaskQueue(new TraceSource("Queue"), "0", new ScaleoutConfiguration() { RetryOnError = true }); queue.Close(); }