Exemple #1
0
 private void VerifyAllReceiversAreStarted(Address address, TransactionSettings settings)
 {
     foreach (var messageReceiver in messageReceivers)
     {
         messageReceiver.Verify(mr => mr.Start(address, settings));
     }
 }
Exemple #2
0
        public void WhenStarted_ThenTheSpecifiedNumberOfReceiversIsCreatedAndStarted()
        {
            TransactionSettings settings        = TransactionSettings.Default;
            const int           NumberOfWorkers = 2;

            var address = new Address("someQueue", "machine");

            testee.Init(address, settings, this.tryReceiveMessage, (s, exception) => { });
            testee.Start(NumberOfWorkers);

            messageReceivers.Count.Should().Be(NumberOfWorkers);
            VerifyAllReceiversAreStarted(address, settings);
        }
        public override void Initialize()
        {
            Address.IgnoreMachineName();

            Environment.SetEnvironmentVariable("AMQ_SSL_ALLOW_DEFAULT_CERT", "true");

            var connectionString = SettingsHolder.Get <string>("NServiceBus.Transport.ConnectionString");
            var parser           = new ConnectionStringBuilder(connectionString);
            var settings         = parser.RetrieveSettings();

            NServiceBus.Configure.Instance.Configurer.RegisterSingleton <WebSphereMqSettings>(settings);

            NServiceBus.Configure.Component <ConnectionFactory>(DependencyLifecycle.SingleInstance);
            NServiceBus.Configure.Component <CurrentSessions>(DependencyLifecycle.SingleInstance);
            NServiceBus.Configure.Component <SubscriptionsManager>(DependencyLifecycle.SingleInstance);

            var transactionSettings = new Unicast.Transport.TransactionSettings();

            if (transactionSettings.IsTransactional)
            {
                if (!transactionSettings.DontUseDistributedTransactions)
                {
                    NServiceBus.Configure.Component <DistributedTransactionMessageReceiver>(DependencyLifecycle.InstancePerCall);
                    NServiceBus.Configure.Component <DistributedTransactionMessageSender>(DependencyLifecycle.InstancePerCall);
                }
                else
                {
                    NServiceBus.Configure.Component <LocalTransactionMessageSender>(DependencyLifecycle.InstancePerCall);
                    NServiceBus.Configure.Component <LocalTransactionMessageReceiver>(DependencyLifecycle.InstancePerCall);
                }
            }
            else
            {
                NServiceBus.Configure.Component <NoTransactionMessageSender>(DependencyLifecycle.InstancePerCall);
                NServiceBus.Configure.Component <NoTransactionMessageReceiver>(DependencyLifecycle.InstancePerCall);
            }

            NServiceBus.Configure.Component <MessagePublisher>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <QueueCreator>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.Settings, settings);
            NServiceBus.Configure.Component <DequeueStrategy>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested)
            .ConfigureProperty(p => p.Settings, settings);
        }
 public void Init(Address address, Unicast.Transport.TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage)
 {
 }
 private void StartTestee(TransactionSettings transactionSettings)
 {
     this.session = this.SetupCreateSession();
     this.testee.Start(transactionSettings);
 }
 private void VerifyAllReceiversAreStarted(Address address, TransactionSettings settings)
 {
     foreach (var messageReceiver in messageReceivers)
     {
         messageReceiver.Verify(mr => mr.Start(address, settings));
     }
 }
 private void StartTestee(TransactionSettings transactionSettings)
 {
     this.session = this.SetupCreateSession();
     this.testee.Start(transactionSettings);
 }