/// <summary> /// Using this extension method will base the queue name of TRequest. /// </summary> /// <typeparam name="TRequest">The query interface/class. Should end with `Query or `Command - otherwise exception is thrown when validating.</typeparam> /// <typeparam name="TResponse">Whatever is expected to be returned.</typeparam> /// <param name="bus">What bus to work with</param> /// <param name="timeout">The timeout before the request is cancelled</param> /// <param name="ttl">THe time to live for the request message</param> /// <param name="callback">Callback when the request is sent</param> /// <returns>The response.</returns> public static IRequestClient <TRequest, TResponse> CreateRequestClient <TRequest, TResponse>(this IBusControl bus, TimeSpan timeout, TimeSpan?ttl = null, Action <SendContext <TRequest> > callback = null) where TRequest : class where TResponse : class { var deliverOnPath = typeof(TRequest).Name; ValidationHelpers.EnsureNamingConventionForCommand(deliverOnPath); var requestUri = new Uri(bus.ExtractBusAddress() + "/" + deliverOnPath); return((IRequestClient <TRequest, TResponse>) new MessageRequestClient <TRequest, TResponse>(bus, requestUri, timeout, ttl, callback)); }
/// <summary> /// See the overloads that work with types instead ot this string. But this can be used as an option. /// </summary> public static async Task <ISendEndpoint> GetSendEndpointAsync(this IBusControl bus, string deliverOnPath) { var newConn = bus.ExtractBusAddress(); if (deliverOnPath == null) { throw new ArgumentNullException($"{nameof(deliverOnPath)}"); } var newUri = new Uri(newConn + "/" + deliverOnPath); var sender = await bus.GetSendEndpoint(newUri); return(sender); }