protected AbstractMsmqListener(
            IQueueStrategy queueStrategy,
            Uri endpoint,
            int threadCount,
            IMessageSerializer messageSerializer,
            IEndpointRouter endpointRouter,
            TransactionalOptions transactional,
            IMessageBuilder<Message> messageBuilder)
        {
            this.queueStrategy = queueStrategy;
            this.messageSerializer = messageSerializer;
            this.endpointRouter = endpointRouter;
            this.endpoint = endpoint;

            this.threadCount = threadCount;
            threads = new Thread[threadCount];

            switch (transactional)
            {
                case TransactionalOptions.Transactional:
                    this.transactional = true;
                    break;
                case TransactionalOptions.NonTransactional:
                    this.transactional = false;
                    break;
                case TransactionalOptions.FigureItOut:
                    this.transactional = null;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("transactional");
            }
            this.messageBuilder = messageBuilder;
            this.messageBuilder.Initialize(Endpoint);
        }
        public IServiceBus CreateServiceBus(MassTransitConnectionDescriptor connectionDescriptor, IQueueStrategy queueStrategy, IReadOnlyList<Action<SubscriptionBusServiceConfigurator>> subscriptions)
        {
            return ServiceBusFactory.New(bus =>
            {
                var receiveUri = new Uri(connectionDescriptor.Host, queueStrategy.GetQueueName());

                bus.UseRabbitMq(r =>
                {
                    r.ConfigureHost(receiveUri, h =>
                    {
                        h.SetUsername(connectionDescriptor.UserName);
                        h.SetPassword(connectionDescriptor.Password);
                    });
                });

                bus.ReceiveFrom(receiveUri);
                bus.UseJsonSerializer();
                bus.SetConcurrentConsumerLimit(_concurrencyLimit);

                foreach (var subscription in subscriptions)
                    bus.Subscribe(subscription);

                bus.Validate();
            });
        }
Exemple #3
0
 public MsmqTransport(IMessageSerializer serializer, IQueueStrategy queueStrategy, Uri endpoint, int threadCount, IMsmqTransportAction[] transportActions, IEndpointRouter endpointRouter, IsolationLevel queueIsolationLevel, TransactionalOptions transactional, bool consumeInTransaction)
     : base(queueStrategy, endpoint, threadCount, serializer, endpointRouter, transactional)
 {
     this.transportActions = transportActions;
     this.queueIsolationLevel = queueIsolationLevel;
     this.consumeInTransaction = consumeInTransaction;
 }
        public static void Test(ITransport t, IQueueStrategy strategy,
            Endpoint queueEndpoint, Action<Message> send, Func<MessageEnumerator>
            enumer)
        {
            Guid id = Guid.NewGuid();
            var serializer = new XmlMessageSerializer(new
                                                          DefaultReflection(), new DefaultKernel());

            var subscriptionStorage = new MsmqSubscriptionStorage(new
                                                                      DefaultReflection(),
                                                                  serializer,
                                                                  queueEndpoint.Uri,
                                                                  new
                                                                      EndpointRouter(),
                                                                  strategy);
            subscriptionStorage.Initialize();

            var wait = new ManualResetEvent(false);

            subscriptionStorage.SubscriptionChanged += () => wait.Set();

            t.AdministrativeMessageArrived +=
                subscriptionStorage.HandleAdministrativeMessage;

            Message msg = new MessageBuilder
                (serializer).GenerateMsmqMessageFromMessageBatch(new
                                                                     AddInstanceSubscription
                {
                    Endpoint = queueEndpoint.Uri.ToString(),
                    InstanceSubscriptionKey = id,
                    Type = typeof (TestMessage2).FullName,
                });
            send(msg);

            wait.WaitOne();

            msg = new MessageBuilder
                (serializer).GenerateMsmqMessageFromMessageBatch(new
                                                                     RemoveInstanceSubscription
                {
                    Endpoint = queueEndpoint.Uri.ToString(),
                    InstanceSubscriptionKey = id,
                    Type = typeof (TestMessage2).FullName,
                });

            wait.Reset();

            send(msg);

            wait.WaitOne();

            IEnumerable<Uri> uris = subscriptionStorage
                .GetSubscriptionsFor(typeof (TestMessage2));
            Assert.Equal(0, uris.Count());

            int count = 0;
            MessageEnumerator copy = enumer();
            while (copy.MoveNext()) count++;
            Assert.Equal(0, count);
        }
        protected AbstractFileListener(
            IQueueStrategy queueStrategy,
            Uri endpoint,
            int threadCount,
            IMessageSerializer messageSerializer,
            IEndpointRouter endpointRouter,
            TransactionalOptions transactional,
            IMessageBuilder <Message> messageBuilder)
        {
            this.queueStrategy     = queueStrategy;
            this.messageSerializer = messageSerializer;
            this.endpointRouter    = endpointRouter;
            this.endpoint          = endpoint;
            this.threadCount       = threadCount;
            threads = new Thread[threadCount];
            switch (transactional)
            {
            case TransactionalOptions.Transactional: this.transactional = true; break;

            case TransactionalOptions.NonTransactional: this.transactional = false; break;

            case TransactionalOptions.FigureItOut: this.transactional = null; break;

            default: throw new ArgumentOutOfRangeException("transactional");
            }
            this.messageBuilder = messageBuilder;
            this.messageBuilder.Initialize(Endpoint);
        }
Exemple #6
0
 public MsmqTransport(IMessageSerializer serializer, IQueueStrategy queueStrategy, Uri endpoint, int threadCount, IMsmqTransportAction[] transportActions, IEndpointRouter endpointRouter, IsolationLevel queueIsolationLevel, TransactionalOptions transactional, bool consumeInTransaction)
     : base(queueStrategy, endpoint, threadCount, serializer, endpointRouter, transactional)
 {
     this.transportActions     = transportActions;
     this.queueIsolationLevel  = queueIsolationLevel;
     this.consumeInTransaction = consumeInTransaction;
 }
 public MsmqReadyForWorkListener(IQueueStrategy queueStrategy,
                                 Uri endpoint,
                                 int threadCount,
                                 IMessageSerializer messageSerializer,
                                 IEndpointRouter endpointRouter,
                                 TransactionalOptions transactional) : base(queueStrategy, endpoint, threadCount, messageSerializer, endpointRouter, transactional)
 {
 }
		public MsmqReadyForWorkListener(IQueueStrategy queueStrategy, 
			Uri endpoint, 
			int threadCount, 
			IMessageSerializer messageSerializer, 
			IEndpointRouter endpointRouter, 
			TransactionalOptions transactional,
            IMessageBuilder<Message> messageBuilder) : base(queueStrategy, endpoint, threadCount, messageSerializer, endpointRouter, transactional, messageBuilder)
		{}
 public MsmqLoadBalancer(
     IMessageSerializer serializer,
     IQueueStrategy queueStrategy,
     IEndpointRouter endpointRouter,
     Uri endpoint,
     int threadCount)
     : base(queueStrategy, endpoint, threadCount, serializer, endpointRouter)
 {
     heartBeatTimer = new Timer(SendHeartBeatToSecondaryServer);
     this.queueStrategy = queueStrategy;
 }
 public MsmqLoadBalancer(
     IMessageSerializer serializer,
     IQueueStrategy queueStrategy,
     IEndpointRouter endpointRouter,
     Uri endpoint,
     int threadCount,
     Uri secondaryLoadBalancer)
     : this(serializer ,queueStrategy, endpointRouter,endpoint, threadCount)
 {
     this.secondaryLoadBalancer = secondaryLoadBalancer;
 }
Exemple #11
0
 public MsmqLoadBalancer(
     IMessageSerializer serializer,
     IQueueStrategy queueStrategy,
     IEndpointRouter endpointRouter,
     Uri endpoint,
     int threadCount,
     TransactionalOptions transactional)
     : base(queueStrategy, endpoint, threadCount, serializer, endpointRouter, transactional)
 {
     heartBeatTimer     = new Timer(SendHeartBeatToSecondaryServer);
     this.queueStrategy = queueStrategy;
 }
Exemple #12
0
 public MsmqLoadBalancer(
     IMessageSerializer serializer,
     IQueueStrategy queueStrategy,
     IEndpointRouter endpointRouter,
     Uri endpoint,
     int threadCount,
     Uri secondaryLoadBalancer,
     TransactionalOptions transactional)
     : this(serializer, queueStrategy, endpointRouter, endpoint, threadCount, transactional)
 {
     this.secondaryLoadBalancer = secondaryLoadBalancer;
 }
Exemple #13
0
 public MessagePublisher(string userName,
                         IRouteConfiguration <IPublishInfo> publishRouteConfiguration,
                         IRouteConfiguration <IConsumeInfo> consumeRouteConfiguration,
                         ISerializationStrategy defaultSerializationStrategy,
                         IQueueStrategy queueStrategy)
 {
     _userName = userName;
     _publishRouteConfiguration    = publishRouteConfiguration;
     _consumeRouteConfiguration    = consumeRouteConfiguration;
     _defaultSerializationStrategy = defaultSerializationStrategy;
     _queueStrategy = queueStrategy;
 }
 public MsmqSubscriptionStorage(
     IReflection reflection,
     IMessageSerializer messageSerializer,
     Uri subscriptionQueue,
     IQueueStrategy queueStrategy
     )
 {
     this.reflection = reflection;
     this.messageSerializer = messageSerializer;
     this.queueStrategy = queueStrategy;
     this.subscriptionQueue = this.queueStrategy.CreateSubscriptionQueueUri(subscriptionQueue);
 }
 public MsmqSecondaryLoadBalancer(
     IMessageSerializer serializer,
     IQueueStrategy queueStrategy,
     IEndpointRouter endpointRouter,
     Uri endpoint,
     Uri primaryLoadBalancer,
     int threadCount)
     : base(serializer, queueStrategy, endpointRouter, endpoint, threadCount)
 {
     TimeoutForHeartBeatFromPrimary = TimeSpan.FromSeconds(10);
     this.primaryLoadBalancer = primaryLoadBalancer;
     tookOverWork = false;
 }
		public MsmqLoadBalancer(
					IMessageSerializer serializer,
					IQueueStrategy queueStrategy,
					IEndpointRouter endpointRouter,
					Uri endpoint,
					int threadCount,
					Uri secondaryLoadBalancer,
					TransactionalOptions transactional,
                    IMessageBuilder<Message> messageBuilder)
			: this(serializer, queueStrategy, endpointRouter, endpoint, threadCount, transactional, messageBuilder)
		{
			this.secondaryLoadBalancer = secondaryLoadBalancer;
		}
		public MsmqLoadBalancer(
			IMessageSerializer serializer,
			IQueueStrategy queueStrategy,
			IEndpointRouter endpointRouter,
			Uri endpoint,
			int threadCount,
			TransactionalOptions transactional,
            IMessageBuilder<Message> messageBuilder)
			: base(queueStrategy, endpoint, threadCount, serializer, endpointRouter, transactional, messageBuilder)
		{
			heartBeatTimer = new Timer(SendHeartBeatToSecondaryServer);
			this.queueStrategy = queueStrategy;
		}
 public MsmqSubscriptionStorage(
     IReflection reflection,
     IMessageSerializer messageSerializer,
     Uri queueBusListensTo,
     IEndpointRouter  endpointRouter,
     IQueueStrategy queueStrategy
     )
 {
     this.reflection = reflection;
     this.messageSerializer = messageSerializer;
     this.endpointRouter = endpointRouter;
     this.queueStrategy = queueStrategy;
     this.subscriptionQueue = this.queueStrategy.CreateSubscriptionQueueUri(queueBusListensTo);
 }
Exemple #19
0
 public MsmqSecondaryLoadBalancer(
     IMessageSerializer serializer,
     IQueueStrategy queueStrategy,
     IEndpointRouter endpointRouter,
     Uri endpoint,
     Uri primaryLoadBalancer,
     int threadCount,
     TransactionalOptions transactional)
     : base(serializer, queueStrategy, endpointRouter, endpoint, threadCount, transactional)
 {
     TimeoutForHeartBeatFromPrimary = TimeSpan.FromSeconds(10);
     this.primaryLoadBalancer       = primaryLoadBalancer;
     tookOverWork = false;
 }
 protected AbstractMsmqListener(
     IQueueStrategy queueStrategy,
     Uri endpoint,
     int threadCount,
     IMessageSerializer messageSerializer,
     IEndpointRouter endpointRouter)
 {
     this.queueStrategy = queueStrategy;
     this.messageSerializer = messageSerializer;
     this.endpointRouter = endpointRouter;
     this.endpoint = endpoint;
     this.threadCount = threadCount;
     threads = new Thread[threadCount];
 }
 public MsmqSubscriptionStorage(
     IReflection reflection,
     IMessageSerializer messageSerializer,
     Uri queueBusListensTo,
     IEndpointRouter endpointRouter,
     IQueueStrategy queueStrategy
     )
 {
     this.reflection        = reflection;
     this.messageSerializer = messageSerializer;
     this.endpointRouter    = endpointRouter;
     this.queueStrategy     = queueStrategy;
     this.subscriptionQueue = this.queueStrategy.CreateSubscriptionQueueUri(queueBusListensTo);
 }
        public IServiceBus CreateServiceBus(MassTransitConnectionDescriptor connectionDescriptor, IQueueStrategy queueStrategy, IReadOnlyList<Action<SubscriptionBusServiceConfigurator>> subscriptions)
        {
            UriBuilder builder = new UriBuilder(connectionDescriptor.Host) {Scheme = "loopback"};

            return ServiceBusFactory.New(bus =>
            {
                var receiveUri = new Uri(builder.Uri, queueStrategy.GetQueueName());

                bus.ReceiveFrom(receiveUri);
                bus.UseJsonSerializer();

                foreach (var subscription in subscriptions)
                    bus.Subscribe(subscription);

                bus.Validate();

            });
        }
 public CreateReadyForWorkQueuesAction(IQueueStrategy queueStrategy, MsmqReadyForWorkListener readyForWorkListener)
 {
     this.queueStrategy        = queueStrategy;
     this.readyForWorkListener = readyForWorkListener;
 }
 public CreateLoadBalancerQueuesAction(IQueueStrategy queueStrategy, MsmqLoadBalancer loadBalancer)
     : base(queueStrategy)
 {
     this.loadBalancer = loadBalancer;
 }
 public CreateLoadBalancerQueuesAction(IQueueStrategy queueStrategy, MsmqLoadBalancer loadBalancer)
     : base(queueStrategy)
 {
     this.loadBalancer = loadBalancer;
 }
        public IServiceBus CreateServiceBus(MassTransitConnectionDescriptor connectionDescriptor, IQueueStrategy queueStrategy, IReadOnlyList <Action <SubscriptionBusServiceConfigurator> > subscriptions)
        {
            return(ServiceBusFactory.New(bus =>
            {
                var receiveUri = new Uri(connectionDescriptor.Host, queueStrategy.GetQueueName());

                bus.UseRabbitMq(r =>
                {
                    r.ConfigureHost(receiveUri, h =>
                    {
                        h.SetUsername(connectionDescriptor.UserName);
                        h.SetPassword(connectionDescriptor.Password);
                    });
                });

                bus.ReceiveFrom(receiveUri);
                bus.UseJsonSerializer();

                bus.ConfigureJsonSerializer(ConfigureIsoDateTimeConverters);
                bus.ConfigureJsonDeserializer(ConfigureIsoDateTimeConverters);

                bus.SetConcurrentConsumerLimit(_concurrencyLimit);

                foreach (var subscription in subscriptions)
                {
                    bus.Subscribe(subscription);
                }

                bus.Validate();
            }));
        }
Exemple #27
0
 public IConfigurationContext WithConnectionUnavailableQueueStrategy(IQueueStrategy queueStrategy)
 {
     ConfigurationModel.ConnectionDownQueueStrategy = queueStrategy;
     return(this);
 }
 public CreateLoadBalancerQueuesAction(IQueueStrategy queueStrategy, MsmqLoadBalancer loadBalancer)
 {
     this.queueStrategy = queueStrategy;
     this.loadBalancer  = loadBalancer;
 }
Exemple #29
0
 public QueueCreationModule(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
 public ErrorDescriptionAction(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
 protected AbstractCreateQueuesAction(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
 public CreateLoadBalancerQueuesAction(IQueueStrategy queueStrategy, MsmqLoadBalancer loadBalancer)
 {
     this.queueStrategy = queueStrategy;
     this.loadBalancer = loadBalancer;
 }
Exemple #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueuePolicy"/> class.
 /// </summary> 
 /// <param name="strategy">The <see cref="IQueueStrategy"/>.</param>
 public QueuePolicy(IQueueStrategy strategy)
 {
     this.strategy = strategy;
 }
 public CreateLogQueueAction(IQueueStrategy queueStrategy, MessageLoggingModule messageLoggingModule, ITransport transport)
     : base(queueStrategy)
 {
     this.messageLoggingModule = messageLoggingModule;
     this.transport = transport;
 }
Exemple #35
0
 public ErrorAction(int numberOfRetries, IQueueStrategy queueStrategy)
 {
     this.numberOfRetries = numberOfRetries;
     this.queueStrategy   = queueStrategy;
 }
 public CreateReadyForWorkQueuesAction(IQueueStrategy queueStrategy, MsmqReadyForWorkListener readyForWorkListener)
 {
     this.queueStrategy = queueStrategy;
     this.readyForWorkListener = readyForWorkListener;
 }
Exemple #37
0
 public MsmqTransport(IMessageSerializer serializer, IQueueStrategy queueStrategy, Uri endpoint, int threadCount, IMsmqTransportAction[] transportActions, IEndpointRouter endpointRouter, IsolationLevel queueIsolationLevel)
     : base(queueStrategy,endpoint, threadCount, serializer,endpointRouter)
 {
     this.transportActions = transportActions;
     this.queueIsolationLevel = queueIsolationLevel;
 }
Exemple #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueuePolicy"/> class.
 /// </summary>
 /// <param name="strategy">The <see cref="IQueueStrategy"/>.</param>
 public QueuePolicy(IQueueStrategy strategy)
 {
     this.strategy = strategy;
 }
 public DiscardAction(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
Exemple #40
0
 public ErrorAction(int numberOfRetries, IQueueStrategy queueStrategy)
 {
     this.numberOfRetries = numberOfRetries;
     this.queueStrategy = queueStrategy;
 }
Exemple #41
0
 public CreateQueuesAction(IQueueStrategy queueStrategy, IServiceBus serviceBus)
 {
     this.queueStrategy = queueStrategy;
     this.serviceBus    = serviceBus;
 }
 public TimeoutAction(IQueueStrategy queueStrategy, ITransactionStrategy transactionStrategy)
 {
     this.queueStrategy       = queueStrategy;
     this.transactionStrategy = transactionStrategy;
 }
        public IServiceBus CreateServiceBus(MassTransitConnectionDescriptor connectionDescriptor, IQueueStrategy queueStrategy, IReadOnlyList <Action <SubscriptionBusServiceConfigurator> > subscriptions)
        {
            UriBuilder builder = new UriBuilder(connectionDescriptor.Host)
            {
                Scheme = "loopback"
            };

            return(ServiceBusFactory.New(bus =>
            {
                var receiveUri = new Uri(builder.Uri, queueStrategy.GetQueueName());

                bus.ReceiveFrom(receiveUri);
                bus.UseJsonSerializer();

                bus.ConfigureJsonSerializer(ConfigureIsoDateTimeConverters);
                bus.ConfigureJsonDeserializer(ConfigureIsoDateTimeConverters);

                foreach (var subscription in subscriptions)
                {
                    bus.Subscribe(subscription);
                }

                bus.Validate();
            }));
        }
Exemple #44
0
        public static void Test(ITransport t, IQueueStrategy strategy,
                                Endpoint queueEndpoint, Action <Message> send, Func <MessageEnumerator>
                                enumer)
        {
            Guid id         = Guid.NewGuid();
            var  serializer = new XmlMessageSerializer(new
                                                       DefaultReflection(), new DefaultKernel());

            var subscriptionStorage = new MsmqSubscriptionStorage(new
                                                                  DefaultReflection(),
                                                                  serializer,
                                                                  queueEndpoint.Uri,
                                                                  new
                                                                  EndpointRouter(),
                                                                  strategy);

            subscriptionStorage.Initialize();

            var wait = new ManualResetEvent(false);

            subscriptionStorage.SubscriptionChanged += () => wait.Set();

            t.AdministrativeMessageArrived +=
                subscriptionStorage.HandleAdministrativeMessage;

            Message msg = new MsmqMessageBuilder
                              (serializer, new DefaultKernel()).BuildFromMessageBatch(new
                                                                                      AddInstanceSubscription
            {
                Endpoint = queueEndpoint.Uri.ToString(),
                InstanceSubscriptionKey = id,
                Type = typeof(TestMessage2).FullName,
            });

            send(msg);

            wait.WaitOne();

            msg = new MsmqMessageBuilder
                      (serializer, new DefaultKernel()).BuildFromMessageBatch(new
                                                                              RemoveInstanceSubscription
            {
                Endpoint = queueEndpoint.Uri.ToString(),
                InstanceSubscriptionKey = id,
                Type = typeof(TestMessage2).FullName,
            });

            wait.Reset();

            send(msg);

            wait.WaitOne();

            IEnumerable <Uri> uris = subscriptionStorage
                                     .GetSubscriptionsFor(typeof(TestMessage2));

            Assert.Equal(0, uris.Count());

            int count = 0;
            MessageEnumerator copy = enumer();

            while (copy.MoveNext())
            {
                count++;
            }
            Assert.Equal(0, count);
        }
 public CreateLogQueueAction(IQueueStrategy queueStrategy, MessageLoggingModule messageLoggingModule, ITransport transport)
     : base(queueStrategy)
 {
     this.messageLoggingModule = messageLoggingModule;
     this.transport            = transport;
 }
 public QueueCreationModule(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
 public CreateQueuesAction(IQueueStrategy queueStrategy, IServiceBus serviceBus)
     : base(queueStrategy)
 {
     this.serviceBus = serviceBus;
 }
Exemple #48
0
 public CreateQueuesAction(IQueueStrategy queueStrategy, IServiceBus serviceBus)
     : base(queueStrategy)
 {
     this.serviceBus = serviceBus;
 }
 public TimeoutAction(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
Exemple #50
0
 public TimeoutAction(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
 protected AbstractCreateQueuesAction(IQueueStrategy queueStrategy)
 {
     this.queueStrategy = queueStrategy;
 }
 public CreateQueuesAction(IQueueStrategy queueStrategy, IServiceBus serviceBus)
 {
     this.queueStrategy = queueStrategy;
     this.serviceBus = serviceBus;
 }