Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OracleMessageBus"/> class.
        /// </summary>
        /// <param name="resolver">The resolver to use.</param>
        /// <param name="configuration">The Oracle scale-out configuration options.</param>
        public OracleMessageBus(IDependencyResolver resolver,
                                OracleScaleoutConfiguration configuration)
            : base(resolver, configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (configuration.UseOracleDependency && configuration.OracleDependencyPort.HasValue)
            {
                OracleDependency.Port = configuration.OracleDependencyPort.Value;
            }

            _connectionString  = configuration.ConnectionString;
            _dbProviderFactory = OracleClientFactory.Instance.AsIDbProviderFactory(configuration.ConnectionString);

            var traceManager = resolver.Resolve <ITraceManager>();

            _trace = traceManager[typeof(OracleMessageBus).Name];

            _dbOperationFactory           = new DbOperationFactory();
            _observableDbOperationFactory = new ObservableDbOperationFactory(null, new OracleDependencyManager(_dbProviderFactory, _trace),
                                                                             new SignalrDbDependencyFactory());
            _useOracleDependency = configuration.UseOracleDependency;

            Task.Run(() => Initialize());
        }
Esempio n. 2
0
        public OracleStream(int streamIndex,
                            string connectionString,
                            bool useOracleDependency,
                            TraceSource traceSource,
                            IDbProviderFactory dbProviderFactory,
                            IDbOperationFactory dbOperationFactory,
                            IObservableDbOperationFactory observableDbOperationFactory)
        {
            _streamIndex = streamIndex;
            _trace       = traceSource;
            _tracePrefix = string.Format(CultureInfo.InvariantCulture, "Stream {0} : ", _streamIndex);
            _cts         = new CancellationTokenSource();

            _messageCollection = new BlockingCollection <MessageWrapper>();
            _sender            = new OracleSender(connectionString, _trace, dbProviderFactory, dbOperationFactory);
            _receiver          = new OracleReceiver(connectionString, useOracleDependency, _trace, dbProviderFactory, dbOperationFactory, observableDbOperationFactory);
            _receiver.Queried += () =>
            {
                if (Queried != null)
                {
                    Queried();
                }
            };
            _receiver.Faulted += ex =>
            {
                if (Faulted != null)
                {
                    Faulted(ex);
                }
            };
            _receiver.Received += OnReceived;
            StartReceiving(_cts.Token);
        }
Esempio n. 3
0
 public OracleReceiver(string connectionString,
                       bool useOracleDependency,
                       TraceSource traceSource,
                       IDbProviderFactory dbProviderFactory,
                       IDbOperationFactory dbOperationFactory,
                       IObservableDbOperationFactory observableDbOperationFactory)
 {
     _connectionString             = connectionString;
     _useOracleDependency          = useOracleDependency;
     _traceSource                  = traceSource;
     _dbProviderFactory            = dbProviderFactory;
     _dbOperationFactory           = dbOperationFactory;
     _observableDbOperationFactory = observableDbOperationFactory;
 }
Esempio n. 4
0
        public void Receiver_Dispose_Success()
        {
            IObservableDbOperationFactory FakeiDbOperationFactory = A.Fake <IObservableDbOperationFactory>();
            var fakeIdbProviderFactoryOperation = A.Fake <IDbProviderFactory>();

            var fakeIDataParameter = A.Fake <IDataParameter>();

            A.CallTo(() => fakeIDataParameter.Value).Returns((long)2);
            var                    fakeCallsTo    = A.CallTo(() => fakeIdbProviderFactoryOperation.CreateParameter()).Returns(fakeIDataParameter);
            IOracleReceiver        oracleReceiver = new OracleReceiver(string.Empty, true, new TraceSource("ss"), fakeIdbProviderFactoryOperation, A.Fake <IDbOperationFactory>(), FakeiDbOperationFactory);
            IObservableDbOperation fakDbOperation = A.Fake <IObservableDbOperation>();
            var                    fake           =
                A.CallTo(() => FakeiDbOperationFactory.ObservableDbOperation(string.Empty, string.Empty, true, new TraceSource("ss"),
                                                                             A.Fake <IDbProviderFactory>())).WithAnyArguments().Returns(fakDbOperation);

            var fakeIObservableDbOperationDispose = A.CallTo(() => fakDbOperation.Dispose());

            oracleReceiver.GetLastPayloadId();
            oracleReceiver.StartReceivingUpdatesFromDb();
            Thread.Sleep(100);
            oracleReceiver.Dispose();

            fakeIObservableDbOperationDispose.MustHaveHappened((Repeated.Exactly.Once));
        }