/// <summary> /// Creates a request client factory which can be used to create a request client per message within a consume context. /// </summary> /// <typeparam name="TRequest"></typeparam> /// <typeparam name="TResponse"></typeparam> /// <param name="host">The host for the response endpoint</param> /// <param name="destinationAddress">The service address</param> /// <param name="timeout">The request timeout</param> /// <param name="timeToLive">The request time to live</param> /// <param name="callback">Customize the send context</param> /// <returns></returns> public static async Task <IRequestClientFactory <TRequest, TResponse> > CreateRequestClientFactory <TRequest, TResponse>(this IServiceBusHost host, Uri destinationAddress, TimeSpan timeout, TimeSpan?timeToLive = default, Action <SendContext <TRequest> > callback = null) where TRequest : class where TResponse : class { var receiveEndpointHandle = host.ConnectResponseEndpoint(); var ready = await receiveEndpointHandle.Ready.ConfigureAwait(false); var context = new HostReceiveEndpointClientFactoryContext(receiveEndpointHandle, ready, timeout); IClientFactory clientFactory = new ClientFactory(context); return(new MessageRequestClientFactory <TRequest, TResponse>(context, clientFactory, destinationAddress, timeToLive, callback)); }
/// <summary> /// Connects a new receive endpoint to the host, and creates a <see cref="IClientFactory"/>. /// </summary> /// <param name="host">The host to connect the new receive endpoint</param> /// <param name="timeout">The default request timeout</param> /// <returns></returns> public static Task <IClientFactory> CreateClientFactory(this IServiceBusHost host, RequestTimeout timeout = default) { var receiveEndpointHandle = host.ConnectResponseEndpoint(); return(receiveEndpointHandle.CreateClientFactory(timeout)); }