示例#1
0
        static void ValidateLocalTransport(ITransportSettings settings)
        {
            MsmqEndpointManagement.Manage(settings.Address, q =>
            {
                if (!q.Exists)
                {
                    if (!settings.CreateIfMissing)
                    {
                        throw new TransportException(settings.Address.Uri,
                                                     "The transport does not exist and automatic creation is not enabled");
                    }

                    q.Create(settings.Transactional || settings.Address.IsTransactional);
                }

                if (settings.RequireTransactional)
                {
                    if (!q.IsTransactional && (settings.Transactional || settings.Address.IsTransactional))
                    {
                        throw new TransportException(settings.Address.Uri,
                                                     "The transport is non-transactional but a transactional transport was requested");
                    }
                }
            });
        }
示例#2
0
 static void PurgeExistingMessagesIfRequested(ITransportSettings settings)
 {
     if (settings.Address.IsLocal && settings.PurgeExistingMessages)
     {
         MsmqEndpointManagement.Manage(settings.Address, x => x.Purge());
     }
 }
        private static LocalTransportSettings ValidateLocalTransport(CreateMsmqTransportSettings settings)
        {
            var result = new LocalTransportSettings
            {
                Transactional = settings.Address.IsTransactional,
            };

            MsmqEndpointManagement.Manage(settings.Address, q =>
            {
                if (!q.Exists)
                {
                    if (!settings.CreateIfMissing)
                    {
                        throw new TransportException(settings.Address.Uri,
                                                     "The transport does not exist and automatic creation is not enabled");
                    }

                    q.Create(settings.Transactional || settings.Address.IsTransactional);
                }

                if (settings.RequireTransactional)
                {
                    if (!q.IsTransactional && (settings.Transactional || settings.Address.IsTransactional))
                    {
                        throw new TransportException(settings.Address.Uri,
                                                     "The transport is non-transactional but a transactional transport was requested");
                    }
                }

                result.Transactional = q.IsTransactional;
            });

            return(result);
        }
示例#4
0
 public static void Manage(IMsmqEndpointAddress address, Action <IEndpointManagement> action)
 {
     try
     {
         var management = new MsmqEndpointManagement(address);
         action(management);
     }
     catch (Exception ex)
     {
         throw new TransportException(address.Uri, "There was a problem managing the transport", ex);
     }
 }
        static void ValidateLocalTransport(ITransportSettings settings)
        {
            MsmqEndpointManagement.Manage(settings.Address, q =>
            {
                if (!q.Exists)
                {
                    if (!settings.CreateIfMissing)
                    {
                        throw new TransportException(settings.Address.Uri,
                                                     "The transport does not exist and automatic creation is not enabled");
                    }

                    q.Create(false);     // multicast queues cannot be transactional
                }
            });
        }
		public static void Manage(IEndpointAddress address, Action<IEndpointManagement> action)
		{
			try
			{
				var management = new MsmqEndpointManagement(address);
				action(management);
			}
			catch (EndpointException)
			{
				throw;
			}
			catch (Exception ex)
			{
				throw new TransportException(address.Uri, "There was a problem managing the transport", ex);
			}
		}