internal static void VerifySender <TChannel>(MsmqChannelFactoryBase <TChannel> factory) { if (!factory.Durable && factory.ExactlyOnce) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqNoAssurancesForVolatile"))); } MsmqChannelFactory <TChannel> factory2 = factory as MsmqChannelFactory <TChannel>; if (((factory2 != null) && factory2.UseActiveDirectory) && (factory2.QueueTransferProtocol != QueueTransferProtocol.Native)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqActiveDirectoryRequiresNativeTransfer"))); } bool?useActiveDirectory = null; if (factory2 != null) { useActiveDirectory = new bool?(factory2.UseActiveDirectory); } VerifySecurity(factory.MsmqTransportSecurity, useActiveDirectory); if (null != factory.CustomDeadLetterQueue) { bool flag; if (DeadLetterQueue.Custom != factory.DeadLetterQueue) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqPerAppDLQRequiresCustom"))); } if (!Msmq.IsPerAppDeadLetterQueueSupported) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqPerAppDLQRequiresMsmq4"))); } if (!factory.ExactlyOnce) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqPerAppDLQRequiresExactlyOnce"))); } string formatName = MsmqUri.NetMsmqAddressTranslator.UriToFormatName(factory.CustomDeadLetterQueue); if (!MsmqQueue.IsWriteable(formatName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqDLQNotWriteable"))); } if (!MsmqQueue.TryGetIsTransactional(formatName, out flag) || !flag) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqTransactedDLQExpected"))); } } if ((null == factory.CustomDeadLetterQueue) && (DeadLetterQueue.Custom == factory.DeadLetterQueue)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqCustomRequiresPerAppDLQ"))); } if (MsmqAuthenticationMode.Certificate == factory.MsmqTransportSecurity.MsmqAuthenticationMode) { EnsureSecurityTokenManagerPresent <TChannel>(factory); } }
public MsmqOutputSessionChannel(MsmqChannelFactory <IOutputSessionChannel> factory, EndpointAddress to, Uri via, bool manualAddressing) : base(factory, to, via, manualAddressing, factory.MessageVersion) { this.factory = factory; this.encoder = this.factory.MessageEncoderFactory.CreateSessionEncoder(); this.buffers = new List <ArraySegment <byte> >(); this.buffers.Add(this.EncodeSessionPreamble()); if (factory.IsMsmqX509SecurityConfigured) { this.certificateTokenProvider = factory.CreateX509TokenProvider(to, via); } this.session = new OutputSession(); }
public MsmqOutputChannel(MsmqChannelFactory <IOutputChannel> factory, EndpointAddress to, Uri via, bool manualAddressing) : base(factory, to, via, manualAddressing, factory.MessageVersion) { byte[] modeBytes = ClientSingletonSizedEncoder.ModeBytes; EncodedVia via2 = new EncodedVia(this.Via.AbsoluteUri); EncodedContentType contentType = EncodedContentType.Create(factory.MessageEncoderFactory.Encoder.ContentType); this.preamble = DiagnosticUtility.Utility.AllocateByteArray(modeBytes.Length + ClientSingletonSizedEncoder.CalcStartSize(via2, contentType)); Buffer.BlockCopy(modeBytes, 0, this.preamble, 0, modeBytes.Length); ClientSingletonSizedEncoder.EncodeStart(this.preamble, modeBytes.Length, via2, contentType); this.outputMessages = new SynchronizedDisposablePool <MsmqOutputMessage <IOutputChannel> >(factory.MaxPoolSize); if (factory.IsMsmqX509SecurityConfigured) { this.certificateTokenProvider = factory.CreateX509TokenProvider(to, via); } this.factory = factory; }
public MsmqOutputChannel(MsmqChannelFactory <IOutputChannel> factory, EndpointAddress address, Uri via) : base(factory, address, via) { this.source = factory; }
internal static void VerifySender <TChannel>(MsmqChannelFactoryBase <TChannel> factory) { // no assurances if messages are volatile if (!factory.Durable && factory.ExactlyOnce) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqNoAssurancesForVolatile))); } MsmqChannelFactory <TChannel> transportFactory = factory as MsmqChannelFactory <TChannel>; if (null != transportFactory && transportFactory.UseActiveDirectory && QueueTransferProtocol.Native != transportFactory.QueueTransferProtocol) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqActiveDirectoryRequiresNativeTransfer))); } bool?useActiveDirectory = null; if (null != transportFactory) { useActiveDirectory = transportFactory.UseActiveDirectory; } VerifySecurity(factory.MsmqTransportSecurity, useActiveDirectory); if (null != factory.CustomDeadLetterQueue) { if (DeadLetterQueue.Custom != factory.DeadLetterQueue) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqPerAppDLQRequiresCustom))); } if (!Msmq.IsPerAppDeadLetterQueueSupported) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqPerAppDLQRequiresMsmq4))); } if (!factory.ExactlyOnce) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqPerAppDLQRequiresExactlyOnce))); } string dlqFormatName = MsmqUri.NetMsmqAddressTranslator.UriToFormatName(factory.CustomDeadLetterQueue); if (!MsmqQueue.IsWriteable(dlqFormatName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqDLQNotWriteable))); } bool isQueueTx; if (!MsmqQueue.TryGetIsTransactional(dlqFormatName, out isQueueTx) || !isQueueTx) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqTransactedDLQExpected))); } } if (null == factory.CustomDeadLetterQueue && DeadLetterQueue.Custom == factory.DeadLetterQueue) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqCustomRequiresPerAppDLQ))); } // token provider needed if Certificate mode requested if (MsmqAuthenticationMode.Certificate == factory.MsmqTransportSecurity.MsmqAuthenticationMode) { EnsureSecurityTokenManagerPresent <TChannel>(factory); } }