public async Task The_user_should_be_pending() { var timer = Stopwatch.StartNew(); var controller = new RegisterUserController(Bus); HostReceiveEndpointHandle connectReceiveEndpoint = null; try { connectReceiveEndpoint = Host.ConnectReceiveEndpoint(NewId.NextGuid().ToString(), x => x.Instance(controller)); await connectReceiveEndpoint.Ready; bool complete = controller.RegisterUser("username", "password", "Display Name", "*****@*****.**"); complete.ShouldBe(true); //("The user should be pending"); timer.Stop(); Debug.WriteLine("Time to handle message: {0}ms", timer.ElapsedMilliseconds); complete = controller.ValidateUser(); complete.ShouldBe(true); //("The user should be complete"); } finally { if (connectReceiveEndpoint != null) { await connectReceiveEndpoint.StopAsync(); } } }
/// <summary> /// Connects a client factory to a host receive endpoint, using the bus as the send endpoint provider /// </summary> /// <param name="receiveEndpointHandle"> /// A handle to the receive endpoint, which is stopped when the client factory is disposed /// </param> /// <param name="timeout"></param> /// <returns></returns> public static async Task <IClientFactory> CreateClientFactory(this HostReceiveEndpointHandle receiveEndpointHandle, RequestTimeout timeout = default) { var ready = await receiveEndpointHandle.Ready.ConfigureAwait(false); var context = new HostReceiveEndpointClientFactoryContext(receiveEndpointHandle, ready, timeout); return(new ClientFactory(context)); }
public async Task CloseAsync(CancellationToken cancellationToken) { if (_handle != null) { await _handle.StopAsync(cancellationToken).ConfigureAwait(false); } _handle = null; }
public async Task DisconnectEndpoint(HostReceiveEndpointHandle handle) { await handle.StopAsync(); if (ActiveReceiveEndpoints.Contains(handle)) { ActiveReceiveEndpoints.Remove(handle); } }
public MessageRequestClientFactory(HostReceiveEndpointHandle endpointHandle, IRequestPipeConnector connector, Uri responseAddress, Uri destinationAddress, TimeSpan timeout, TimeSpan?timeToLive, Action <SendContext <TRequest> > callback) { _endpointHandle = endpointHandle; _connector = connector; _responseAddress = responseAddress; _destinationAddress = destinationAddress; _timeout = timeout; _timeToLive = timeToLive; _callback = callback; }
public async Task <string> OpenAsync(CancellationToken cancellationToken) { try { _handle = await _extendedHost.ConnectReceiveEndpoint(_queueName, configurator => { configurator.Consumer(() => _consumer); if (_autoDelete) { configurator.ConfigureExchange(false, true); } _configure?.Invoke(configurator); }); var address = _handle.Ready.Result.InputAddress.ToString(); Log.Info($"MassTransit Listening on: {address}"); return(address); } catch (Exception ex) { Log.Error(ex, $"Error Configuring MassTransit Queue: {_queueName}"); throw; } }
public void Abort() { _handle?.StopAsync().Wait(1000); _handle = null; }
public HostReceiveEndpointClientFactoryContext(HostReceiveEndpointHandle receiveEndpointHandle, ReceiveEndpointReady receiveEndpointReady, RequestTimeout defaultTimeout = default) : base(receiveEndpointReady, defaultTimeout) { _receiveEndpointHandle = receiveEndpointHandle; }
protected BaseHostHandle(IHost host, HostReceiveEndpointHandle[] handles) { _host = host; _handles = handles; }