/// <summary> /// Initializes a new instance of the <see cref="MsmqMessageQueue"/> class /// </summary> /// <param name="options">Options for creating the queue</param> /// <param name="transactional">Pass true to create a transactional queue</param> /// <param name="accessControl">List of accounts that have specific control over the queue</param> public MsmqMessageQueue(QueueCreationOptions options, bool transactional, AccessControlList accessControl = null) { // TODO: deal with Priority? https://msdn.microsoft.com/en-us/library/system.messaging.message.priority(v=vs.110).aspx _options = options ?? throw new ArgumentNullException(nameof(options)); _accessControl = accessControl; InitializeQueue(options.QueueId, transactional); }
public Mock <IMessageQueue> CreateMock(QueueCreationOptions options) { var mock = _fixture.Create <Mock <IMessageQueue> >(); mock.SetupGet(m => m.Id).Returns(options.QueueId); MockQueues.Add(options.QueueId, mock); return(mock); }
/// <summary> /// Creates a new instance of the <see cref="MsmqMessageQueue"/> class for the specified queueId /// </summary> /// <param name="options">Options for creating the queue</param> /// <exception cref="ServiceNotAvailableException" /> /// <exception cref="MessageQueueException" /> public IMessageQueue Create(QueueCreationOptions options) { try { return(new MsmqMessageQueue(options, false, _accessControl)); } catch (MessageQueueException ex) { if (ex.MessageQueueErrorCode == MessageQueueErrorCode.ServiceNotAvailable) { throw new ServiceNotAvailableException("Cannot create queue", ex); } throw; } }
public ITypedQueue <TMessage> Create <TMessage>(QueueCreationOptions creationOptions) { var creationOptionsType = creationOptions.GetType(); var typedQueuesFactory = _serviceProvider.GetService(_typedQueuesFactoryType.MakeGenericType(creationOptionsType)); var createMethodDefinition = typedQueuesFactory.GetType() .GetMethods() .Single(x => x.IsGenericMethod && x.Name == nameof(ITypedQueuesFactory <QueueCreationOptions> .Create)) .MakeGenericMethod(typeof(TMessage)); try { return((ITypedQueue <TMessage>)createMethodDefinition.Invoke(typedQueuesFactory, new object[] { creationOptions })); } catch (TargetInvocationException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } return(default(ITypedQueue <TMessage>)); }
public IMessageQueue Create(QueueCreationOptions options) { return(CreateMock(options).Object); }