public async Task<IRequestResult> Dispatch(IMessage message, ISinkQualityAttributes attrs) { RequestResult result = RequestResult.Create(); this.GuardedExecutionAsync(async () => { var client = new HttpClient(); client.Timeout = TimeSpan.FromMilliseconds(attrs.RequestTimeout.HasValue ? attrs.RequestTimeout.Value : DefaultTimeout); // This is somewhat of a cheat. The expectation is that the body WILL be a string var body = message.Body.IsNull() || message.Body.Ancillary.IsNull() ? String.Empty : message.Body.Ancillary; var res = await client.PostAsync(Target, new StringContent(body, Encoding.ASCII, MimeType)); result.Success = AcceptableStatusCodes.Contains(res.StatusCode); }, ex => { result.Success = false; result.Message = ex.ToString(); }); return result; }
public async Task <IRequestResult> Dispatch(IMessage message, ISinkQualityAttributes attrs) { RequestResult result = RequestResult.Create(); this.GuardedExecutionAsync(async() => { var client = new HttpClient(); client.Timeout = TimeSpan.FromMilliseconds(attrs.RequestTimeout.HasValue ? attrs.RequestTimeout.Value : DefaultTimeout); // This is somewhat of a cheat. The expectation is that the body WILL be a string var body = message.Body.IsNull() || message.Body.Ancillary.IsNull() ? String.Empty : message.Body.Ancillary; var res = await client.PostAsync(Target, new StringContent(body, Encoding.ASCII, MimeType)); result.Success = AcceptableStatusCodes.Contains(res.StatusCode); }, ex => { result.Success = false; result.Message = ex.ToString(); }); return(result); }
public async Task<IRequestResult> Dispatch(IMessage message, ISinkQualityAttributes attrs) { return this.ExecuteWithResult(() => Console.WriteLine("Received message: " + message.TopicName)); }
public async Task <IRequestResult> Dispatch(IMessage message, ISinkQualityAttributes attrs) { return(this.ExecuteWithResult(() => Console.WriteLine("Received message: " + message.TopicName))); }