예제 #1
0
        Task IPublishEndpoint.Publish <T>(object values, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            var message = TypeMetadataCache <T> .InitializeFromObject(values);

            var adapter = new PublishEndpointPipeAdapter <T>(publishPipe, _publishPipe, _publishObserver, _sourceAddress, _consumeContext, message);

            return(Publish(cancellationToken, message, adapter));
        }
예제 #2
0
        async Task Publish <T>(CancellationToken cancellationToken, T message, PublishEndpointPipeAdapter <T> adapter)
            where T : class
        {
            try
            {
                var sendEndpoint = await _endpointProvider.GetPublishSendEndpoint(message).ConfigureAwait(false);

                await sendEndpoint.Send(message, adapter, cancellationToken).ConfigureAwait(false);

                await adapter.PostPublish().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await adapter.PublishFaulted(ex).ConfigureAwait(false);

                throw;
            }
        }
예제 #3
0
        Task IPublishEndpoint.Publish <T>(T message, IPipe <PublishContext> publishPipe, CancellationToken cancellationToken)
        {
            var adapter = new PublishEndpointPipeAdapter <T>(publishPipe, _publishPipe, _publishObserver, _sourceAddress, _consumeContext);

            return(Publish(cancellationToken, message, adapter));
        }