public SendEndpoint(ISendTransport transport, IMessageSerializer serializer, Uri destinationAddress, Uri sourceAddress, ISendPipe sendPipe, ConnectHandle observerHandle = null) { _transport = transport; _sendPipe = sendPipe; _observerHandle = observerHandle; Serializer = serializer; DestinationAddress = destinationAddress; SourceAddress = sourceAddress; }
async Task <CachedSendEndpoint <TypeKey> > CreateSendEndpoint <T>(TypeKey typeKey) where T : class { var builder = _host.CreatePublishTopologyBuilder(); _publishTopology.GetMessageTopology <T>().Apply(builder); ISendTransport exchange = await _host.GetSendTransport(typeKey.Address).ConfigureAwait(false); var sendEndpoint = new SendEndpoint(exchange, _serializer, typeKey.Address, _sourceAddress, SendPipe.Empty); return(new CachedSendEndpoint <TypeKey>(typeKey, sendEndpoint)); }
async Task IFilter <ReceiveContext> .Send(ReceiveContext context, IPipe <ReceiveContext> next) { ISendTransport transport = await _getDestinationTransport.Value.ConfigureAwait(false); IPipe <SendContext> pipe = Pipe.Execute <SendContext>(sendContext => { sendContext.Headers.Set(MessageHeaders.Reason, _reason); sendContext.SetHostHeaders(); }); await transport.Move(context, pipe).ConfigureAwait(false); await next.Send(context).ConfigureAwait(false); }
async Task IFilter <ReceiveContext> .Send(ReceiveContext context, IPipe <ReceiveContext> next) { ISendTransport transport = await _getDestinationTransport(); IPipe <SendContext> pipe = Pipe.Execute <SendContext>(sendContext => { sendContext.Headers.Set("MT-Reason", _reason); sendContext.SetHostHeaders(); }); await transport.Move(context, pipe); await next.Send(context); }
async Task IFilter <ExceptionReceiveContext> .Send(ExceptionReceiveContext context, IPipe <ExceptionReceiveContext> next) { ISendTransport transport = await _getDestinationTransport(); IPipe <SendContext> pipe = Pipe.Execute <SendContext>(sendContext => { sendContext.Headers.Set("MT-Reason", "fault"); Exception exception = context.Exception.GetBaseException(); sendContext.Headers.Set("MT-Fault-Message", exception.Message); sendContext.Headers.Set("MT-Fault-StackTrace", exception.StackTrace); sendContext.SetHostHeaders(); }); await transport.Move(context, pipe); await next.Send(context); }
public CachedSendTransport(Uri address, ISendTransport sendTransport) { Address = address; _sendTransport = sendTransport; }
public async Task <ISendEndpoint> GetSendEndpoint(Uri address) { ISendTransport transport = await _transportProvider.GetSendTransport(address).ConfigureAwait(false); return(new SendEndpoint(transport, _serializer, address, _sourceAddress, _sendPipe)); }