Пример #1
0
        public override Task InvokeAsync(IPipeContext context, CancellationToken token)
        {
            var config = ExtractConfigFromMessageType(context) ?? ExtractConfigFromStrings(context);

            if (config == null)
            {
                _logger.Warn("Unable to find PublisherConfiguration from message type or parameters.");
                throw new ArgumentNullException(nameof(config));
            }

            var action = context.Get <Action <IPublisherConfigurationBuilder> >(PipeKey.ConfigurationAction);

            if (action != null)
            {
                _logger.Debug($"Custom configuration supplied. Applying.");
                var builder = new PublisherConfigurationBuilder(config);
                action(builder);
                config = builder.Config;
            }

            context.Properties.TryAdd(PipeKey.PublisherConfiguration, config);
            context.Properties.TryAdd(PipeKey.BasicPublishConfiguration, config);
            context.Properties.TryAdd(PipeKey.ExchangeDeclaration, config.Exchange);
            context.Properties.TryAdd(PipeKey.BasicProperties, config.BasicProperties);
            context.Properties.TryAdd(PipeKey.ReturnCallback, config.ReturnCallback);

            return(Next.InvokeAsync(context, token));
        }
Пример #2
0
        public override Task InvokeAsync(IPipeContext context, CancellationToken token)
        {
            var requestType  = _requestTypeFunc(context);
            var responseType = _responseTypeFunc(context);
            var action       = context.Get <Action <IRespondConfigurationBuilder> >(PipeKey.ConfigurationAction);

            if (requestType == null)
            {
                throw new ArgumentNullException(nameof(requestType));
            }
            if (responseType == null)
            {
                throw new ArgumentNullException(nameof(responseType));
            }
            var defaultCfg = _factory.Create(requestType, responseType);

            var builder = new RespondConfigurationBuilder(defaultCfg);

            action?.Invoke(builder);

            var respondCfg = builder.Config;

            context.Properties.TryAdd(PipeKey.ConsumerConfiguration, respondCfg);
            context.Properties.TryAdd(PipeKey.ConsumeConfiguration, respondCfg.Consume);
            context.Properties.TryAdd(PipeKey.QueueDeclaration, respondCfg.Queue);
            context.Properties.TryAdd(PipeKey.ExchangeDeclaration, respondCfg.Exchange);

            return(Next.InvokeAsync(context, token));
        }
        public override Task InvokeAsync(IPipeContext context, CancellationToken token)
        {
            var requestType  = context.GetRequestMessageType();
            var responseType = context.GetResponseMessageType();

            if (requestType == null)
            {
                throw new ArgumentNullException(nameof(requestType));
            }
            if (responseType == null)
            {
                throw new ArgumentNullException(nameof(responseType));
            }

            var defaultCfg = _factory.Create(requestType, responseType);

            var builder = new RequestConfigurationBuilder(defaultCfg);
            var action  = context.Get <Action <IRequestConfigurationBuilder> >(PipeKey.ConfigurationAction);

            action?.Invoke(builder);
            var requestConfig = builder.Config;

            context.Properties.TryAdd(RequestKey.Configuration, requestConfig);
            context.Properties.TryAdd(PipeKey.PublisherConfiguration, requestConfig.Request);
            context.Properties.TryAdd(PipeKey.ConsumerConfiguration, requestConfig.Response);
            context.Properties.TryAdd(PipeKey.ConsumeConfiguration, requestConfig.Response.Consume);
            return(Next.InvokeAsync(context, token));
        }
 public static Action <IPipeBuilder> GetPipeBuilderAction(this IPipeContext context)
 {
     return(context.Get <Action <IPipeBuilder> >(StateMachineKey.PipeBuilderAction));
 }
 public static Action <IPipeContext> GetContextAction(this IPipeContext context)
 {
     return(context.Get <Action <IPipeContext> >(StateMachineKey.ContextAction));
 }
 public static bool GetApplicationSuffixFlag(this IPipeContext context)
 {
     return(context.Get(ApplicationQueueSuffix, true));
 }
 public static object GetResponseMessage(this IPipeContext context)
 {
     return(context.Get <object>(RequestKey.ResponseMessage));
 }
        public static object[] GetLazyHandlerArgs(this IPipeContext context)
        {
            var func = context.Get <Func <IPipeContext, Func <IPipeContext, object[]> > >(StateMachineKey.LazyHandlerArgsFunc);

            return(func?.Invoke(context)?.Invoke(context));
        }
 public static Microsoft.AspNetCore.Http.HttpContext GetHttpContext(this IPipeContext pipeContext)
 {
     return(pipeContext.Get <Microsoft.AspNetCore.Http.HttpContext>(HttpContext));
 }
 public static bool GetCustomQueueSuffixActivated(this IPipeContext context)
 {
     return(context.Get(CustomQueueSuffixActivated, true));
 }
Пример #11
0
 public static GetConfiguration GetGetConfiguration(this IPipeContext context)
 {
     return(context.Get <GetConfiguration>(GetConfiguration));
 }
 public static RequestConfiguration GetRequestConfiguration(this IPipeContext context)
 {
     return(context.Get <RequestConfiguration>(RequestKey.Configuration));
 }
 public static string GetCustomQueueSuffix(this IPipeContext context)
 {
     return(context.Get <string>(CustomQueueSuffix));
 }
 public static PublicationAddress GetPublicationAddress(this IPipeContext context)
 {
     return(context.Get <PublicationAddress>(RequestKey.PublicationAddress));
 }
 public static Type GetRequestMessageType(this IPipeContext context)
 {
     return(context.Get <Type>(RequestKey.OutgoingMessageType));
 }
 public static string GetCorrelationId(this IPipeContext context)
 {
     return(context.Get <string>(RequestKey.CorrelationId));
 }
 public static Func <object[], Guid> GetIdCorrelationFunc(this IPipeContext context)
 {
     return(context.Get <Func <object[], Guid> >(StateMachineKey.CorrelationFunc));
 }
Пример #18
0
 public static BasicGetResult GetBasicGetResult(this IPipeContext context)
 {
     return(context.Get <BasicGetResult>(BasicGetResult));
 }
        public static object[] GetLazyCorrelationArgs(this IPipeContext context)
        {
            var func = context.Get <Func <IPipeContext, Func <IPipeContext, object[]> > >(StateMachineKey.LazyCorrelationFuncArgs);

            return(func?.Invoke(context)?.Invoke(context));
        }
Пример #20
0
        public static Policy GetPolicy(this IPipeContext context, string policyName = null)
        {
            var fallback = context.Get <Policy>(PolicyKeys.DefaultPolicy);

            return(context.Get(policyName, fallback));
        }
 public static StateMachineBase GetStateMachine(this IPipeContext context)
 {
     return(context.Get <StateMachineBase>(StateMachineKey.Machine));
 }
Пример #22
0
 public static bool GetHostnameQueueSuffixFlag(this IPipeContext context)
 {
     return(context.Get(HostnameQueueSuffixActive, true));
 }
 public static System.Web.HttpContext GetHttpContext(this IPipeContext pipeContext)
 {
     return(pipeContext.Get <System.Web.HttpContext>(HttpContext));
 }
 public static Func <IPipeContext, object> GetMessageContextResolver(this IPipeContext context)
 {
     return(context.Get <Func <IPipeContext, object> >(PipebasedContextFunc));
 }
 public static bool GetDedicatedResponseConsumer(this IPipeContext context)
 {
     return(context.Get(DedicatedResponseConsumer, false));
 }
 public static Type GetResponseMessageType(this IPipeContext context)
 {
     return(context.Get <Type>(RequestKey.IncommingMessageType));
 }
 public static string GetGlobalExecutionId(this IPipeContext context)
 {
     return(context.Get <string>(PipeKey.GlobalExecutionId));
 }
Пример #28
0
 public static bool GetWildcardRoutingSuffixActive(this IPipeContext context)
 {
     return(context.Get(SubscribeWithWildCard, true));
 }
 public static Type GetMessageContextType(this IPipeContext context)
 {
     return(context.Get(MessageContextType, typeof(object)));
 }
 public static Guid GetModelId(this IPipeContext context)
 {
     return(context.Get <Guid>(StateMachineKey.ModelId));
 }