public void ChangeWorkerRole2(string worker_role) { queue.AddMessage(new CloudQueueMessage(worker_role)); Trace.WriteLine("Selected Entity Handler: " + worker_role); NetTcpBinding binding2 = new NetTcpBinding(); EndpointAddress address = new EndpointAddress("net.tcp://localhost:8901/InputRequest_QueueRequest"); ChannelFactory <IQueueRequest> channelFactory = new ChannelFactory <IQueueRequest>(binding2, address); IQueueRequest proxy = channelFactory.CreateChannel(); proxy.QueueMessage(); }
private async Task <IQueueResponse> ProcessQueueItem(IQueueRequest queueItem) { using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }, TransactionScopeAsyncFlowOption.Enabled)) { var stopwatch = GetStopwatch(); try { IQueueResponse queueResponse = null; using (var connection = new SqlConnection(ConnectionString.DefaultConnection)) { switch (queueItem) { case SubmitPixelRequest request: queueResponse = await ProcessSubmitPixelRequest(connection, request); break; case SubmitClickRequest request: queueResponse = await ProcessSubmitClickRequest(connection, request); break; } transactionScope.Complete(); } return(queueResponse); } catch (QueueException tex) { Log.Message(LogLevel.Error, $"[QueueException] - Exception: {tex.Message}"); return(new QueueErrorResponse(tex.Message)); } catch (Exception ex) { Log.Exception($"[ProcessServiceRequest] - An unknown exception occurred during processing", ex); return(new QueueErrorResponse("Unknown Error")); } } }
/// <summary> /// The value to convert to a string and set for this key's node. /// </summary> public static IQueueRequest WithValue <T>(this IQueueRequest This, T value, IKeyDataValueConverter valueConverter = null) { return(This.WithValue(Convert(This.EtcdClient.Config, value, valueConverter))); }
/// <summary> /// An optional expiration for this key. /// </summary> public static IQueueRequest WithTimeToLive(this IQueueRequest This, TimeSpan?timeSpan) { return(This.ApplyTimeToLive(timeSpan, (x, y) => x.WithTimeToLive(y))); }