コード例 #1
0
        //Create an instance of the ExternalBusServices if one not already set for this app. Note that we do not support reinitialization here, so once you have
        //set a command processor for the app, you can't call init again to set them - although the properties are not read-only so overwriting is possible
        //if needed as a "get out of gaol" card.
        private void InitExtServiceBus(IPolicyRegistry <string> policyRegistry,
                                       IAmAnOutbox <Message> outbox,
                                       int outboxTimeout,
                                       IAmAProducerRegistry producerRegistry)
        {
            if (_bus == null)
            {
                lock (padlock)
                {
                    if (_bus == null)
                    {
                        if (producerRegistry == null)
                        {
                            throw new ConfigurationException("A producer registry is required to create an external bus");
                        }

                        _bus = new ExternalBusServices();
                        if (outbox is IAmAnOutboxSync <Message> syncOutbox)
                        {
                            _bus.OutBox = syncOutbox;
                        }
                        if (outbox is IAmAnOutboxAsync <Message> asyncOutbox)
                        {
                            _bus.AsyncOutbox = asyncOutbox;
                        }

                        _bus.OutboxTimeout    = outboxTimeout;
                        _bus.PolicyRegistry   = policyRegistry;
                        _bus.ProducerRegistry = producerRegistry;
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// The external service bus is a singleton as it has app lifetime to manage an Outbox.
 /// This method clears the external service bus, so that the next attempt to use it will create a fresh one
 /// It is mainly intended for testing, to allow the external service bus to be reset between tests
 /// </summary>
 public static void ClearExtServiceBus()
 {
     if (_bus != null)
     {
         lock (padlock)
         {
             if (_bus != null)
             {
                 _bus.Dispose();
                 _bus = null;
             }
         }
     }
 }