Ejemplo n.º 1
0
 public HttpTransportService(Uri baseUri, IEndpointCollection endpoints,
                             IMessageQueueingService messageQueueingService, IMessageJournal messageJournal,
                             ISubscriptionTrackingService subscriptionTrackingService,
                             bool bypassTransportLocalDestination = false,
                             IDiagnosticService diagnosticService = null)
     : this(new HttpTransportServiceOptions(baseUri, messageQueueingService, subscriptionTrackingService)
 {
     DiagnosticService = diagnosticService,
     Endpoints = endpoints,
     MessageJournal = messageJournal,
     BypassTransportLocalDestination = bypassTransportLocalDestination,
     HttpClientFactory = new BasicHttpClientFactory()
 })
 {
 }
Ejemplo n.º 2
0
        public HttpTransportService(Uri baseUri, IEndpointCollection endpoints, IMessageQueueingService messageQueueingService, IMessageJournalingService messageJournalingService, ISubscriptionTrackingService subscriptionTrackingService)
        {
            if (baseUri == null) throw new ArgumentNullException("baseUri");
            if (messageQueueingService == null) throw new ArgumentNullException("messageQueueingService");
            if (subscriptionTrackingService == null) throw new ArgumentNullException("subscriptionTrackingService");

            _baseUri = baseUri;
            _endpoints = endpoints == null
                ? ReadOnlyEndpointCollection.Empty
                : new ReadOnlyEndpointCollection(endpoints);

            _messageQueueingService = messageQueueingService;
            _messageJournalingService = messageJournalingService;
            _subscriptionTrackingService = subscriptionTrackingService;
            _outboundQueueName = "Outbound";
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new <see cref="HttpTransportService"/>
        /// </summary>
        /// <param name="options">The HTTP transport service configuration</param>
        public HttpTransportService(HttpTransportServiceOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _baseUri   = options.BaseUri.WithTrailingSlash();
            _endpoints = options.Endpoints = options.Endpoints ?? EndpointCollection.Empty;

            _messageQueueingService          = options.MessageQueueingService;
            _messageJournal                  = options.MessageJournal;
            _subscriptionTrackingService     = options.SubscriptionTrackingService;
            _bypassTransportLocalDestination = options.BypassTransportLocalDestination;
            _diagnosticService               = options.DiagnosticService ?? DiagnosticService.DefaultInstance;
            _httpClientFactory               = options.HttpClientFactory ?? new BasicHttpClientFactory();
            _outboundQueueName               = "Outbound";
        }
Ejemplo n.º 4
0
        public Endpoint(string route, Service service, IEndpointCollection endpointCollection)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service", "service cannot be null.");
            }

            if (endpointCollection == null)
            {
                throw new ArgumentNullException("endpointCollection", "endpointCollection cannot be null.");
            }

            this.Route = RoutePattern.Parse(service.BaseUrl.AppendUrlPath(route));
            this.EndpointCollection = endpointCollection;
            this.Methods = new MethodCollection(this);
            this.ParameterPatterns = new Dictionary<string, Regex>();
            this.ParameterTypes = new Dictionary<string, Type>();
            this.Pipeline = new Pipeline();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new <see cref="Bus"/> with the specified configuration and services
        /// provided by the host
        /// </summary>
        /// <param name="configuration">The core bus configuration</param>
        /// <param name="baseUri">The base URI provided by the host</param>
        /// <param name="transportService">The transport service provided by the host</param>
        /// <param name="messageQueueingService">The message queueing service provided by the host</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the parameters are <c>null</c></exception>
        public Bus(IPlatibusConfiguration configuration, Uri baseUri, ITransportService transportService, IMessageQueueingService messageQueueingService)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            // Validate the provided configuration and throw exceptions for missing or invalid
            // configurations
            configuration.Validate();

            _baseUri                = baseUri ?? throw new ArgumentNullException(nameof(baseUri));
            _transportService       = transportService ?? throw new ArgumentNullException(nameof(transportService));
            _messageQueueingService = messageQueueingService ?? throw new ArgumentNullException(nameof(messageQueueingService));
            _defaultContentType     = string.IsNullOrWhiteSpace(configuration.DefaultContentType)
                ? "application/json"
                : configuration.DefaultContentType;

            _defaultSendOptions = configuration.DefaultSendOptions ?? new SendOptions();

            _messageMarshaller = new MessageMarshaller(
                configuration.MessageNamingService,
                configuration.SerializationService,
                configuration.DefaultContentType);

            _endpoints     = configuration.Endpoints ?? EndpointCollection.Empty;
            _topics        = configuration.Topics.ToList();
            _sendRules     = configuration.SendRules.ToList();
            _handlingRules = configuration.HandlingRules.ToList();
            _subscriptions = configuration.Subscriptions.ToList();

            _diagnosticService = configuration.DiagnosticService;
            _messageHandler    = new MessageHandler(_messageMarshaller, _diagnosticService);

            _transportService.MessageReceived += OnMessageReceived;

            _replyHub = new MemoryCacheReplyHub(_messageMarshaller, _diagnosticService, TimeSpan.FromMinutes(5));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new <see cref="ReadOnlyEndpointCollection"/> based on the
 /// endpoints in the specified <paramref name="endpointCollection"/>
 /// </summary>
 /// <param name="endpointCollection">An endpoint collection</param>
 public ReadOnlyEndpointCollection(IEndpointCollection endpointCollection)
 {
     if (endpointCollection == null) throw new ArgumentNullException("endpointCollection");
     _endpoints = endpointCollection.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new <see cref="Bus"/> with the specified configuration and services
        /// provided by the host
        /// </summary>
        /// <param name="configuration">The core bus configuration</param>
        /// <param name="baseUri">The base URI provided by the host</param>
        /// <param name="transportService">The transport service provided by the host</param>
        /// <param name="messageQueueingService">The message queueing service provided by the host</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the parameters are <c>null</c></exception>
        public Bus(IPlatibusConfiguration configuration, Uri baseUri, ITransportService transportService, IMessageQueueingService messageQueueingService)
        {
            if (configuration == null) throw new ArgumentNullException("configuration");
            if (baseUri == null) throw new ArgumentNullException("baseUri");
            if (transportService == null) throw new ArgumentNullException("transportService");
            if (messageQueueingService == null) throw new ArgumentNullException("messageQueueingService");

            _baseUri = baseUri;
            _transportService = transportService;
            _messageQueueingService = messageQueueingService;

            // TODO: Throw configuration exception if message queueing service, message naming
            // service, or serialization service are null

            _messageJournalingService = configuration.MessageJournalingService;
            _messageNamingService = configuration.MessageNamingService;
            _serializationService = configuration.SerializationService;

            _endpoints = new ReadOnlyEndpointCollection(configuration.Endpoints);
            _topics = configuration.Topics.ToList();
            _sendRules = configuration.SendRules.ToList();
            _handlingRules = configuration.HandlingRules.ToList();
            _subscriptions = configuration.Subscriptions.ToList();
        }