コード例 #1
0
        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);
        }
コード例 #2
0
        private static IMsmqTransport NewLocalTransport(CreateMsmqTransportSettings settings)
        {
            LocalTransportSettings transportSettings = ValidateLocalTransport(settings);

            if (transportSettings.Transactional)
            {
                return(new TransactionalMsmqTransport(settings.Address));
            }

            return(new NonTransactionalMsmqTransport(settings.Address));
        }