Example #1
0
        public IMessagingSession GetMessagingSession(string transportId, string name, Action onFailure = null)
        {
            ResolvedTransport transport = ResolveTransport(transportId);

            try
            {
                return(transport.GetSession(transportId, name, onFailure));
            }
            catch (Exception e)
            {
                throw new TransportException(string.Format("Failed to create processing group {0} on transport {1}", name, transportId), e);
            }
        }
        public IMessagingSession GetMessagingSession(Endpoint endpoint, string name, Action onFailure = null)
        {
            ResolvedTransport transport = ResolveTransport(endpoint.TransportId);

            try
            {
                return(transport.GetSession(endpoint, name, onFailure));
            }
            catch (Exception e)
            {
                throw new TransportException($"Failed to create processing group {name} on transport {endpoint.TransportId}", e);
            }
        }
        public bool VerifyDestination(
            string transportId,
            Destination destination,
            EndpointUsage usage,
            bool configureIfRequired,
            out string error)
        {
            ResolvedTransport transport = ResolveTransport(transportId);

            try
            {
                return(transport.VerifyDestination(
                           destination,
                           usage,
                           configureIfRequired,
                           out error));
            }
            catch (Exception e)
            {
                throw new TransportException($"Destination {destination} is not properly configured on transport {transportId}", e);
            }
        }
        public IDictionary <Endpoint, string> VerifyDestinations(
            string transportId,
            IEnumerable <Endpoint> endpoints,
            EndpointUsage usage,
            bool configureIfRequired)
        {
            var result = new ConcurrentDictionary <Endpoint, string>();

            var failedDestinations      = new ConcurrentDictionary <Destination, string>();
            ResolvedTransport transport = ResolveTransport(transportId);

            Parallel.ForEach(endpoints, endpoint =>
            {
                try
                {
                    bool rerificationResult = transport.VerifyDestination(
                        endpoint.Destination,
                        usage,
                        configureIfRequired,
                        out var dstError);
                    result.TryAdd(endpoint, rerificationResult ? null : dstError);
                }
                catch (Exception e)
                {
                    failedDestinations.TryAdd(endpoint.Destination, e.Message);
                }
            });

            if (failedDestinations.Count > 0)
            {
                throw new TransportException(
                          $"Destinations {string.Join(", ", failedDestinations.Keys)} are not properly configured on transport {transportId}:{Environment.NewLine}"
                          + $"{string.Join($",{Environment.NewLine}", failedDestinations.Values)}");
            }

            return(result);
        }