Example #1
0
        private void ProcessRecord(IDataRecord record, IDbOperation dbOperation)
        {
            long            id      = record.GetInt64(0);
            ScaleoutMessage message = OraclePayload.FromBytes(record);

            _traceSource.TraceVerbose("OracleReceiver last payload ID={0}, new payload ID={1}", _lastPayloadId, id);

            if (id > _lastPayloadId + 1)
            {
                _traceSource.TraceError("Missed message(s) from Oracle. Expected payload ID {0} but got {1}.", _lastPayloadId + 1, id);
            }
            else if (id <= _lastPayloadId)
            {
                _traceSource.TraceInformation("Duplicate message(s) or payload ID reset from Oracle. Last payload ID {0}, this payload ID {1}", _lastPayloadId, id);
            }

            _lastPayloadId = id;
            dbOperation.Parameters[0].Value = _lastPayloadId;

            _traceSource.TraceVerbose("Updated receive reader initial payload ID parameter={0}", _observableDbOperation.Parameters[0].Value);
            _traceSource.TraceVerbose("Payload {0} containing {1} message(s) received", id, message.Messages.Count);

            if (Received != null)
            {
                Received((ulong)id, message);
            }
        }
        public Task Send(IList <Message> messages)
        {
            if (messages == null || messages.Count == 0)
            {
                return(MakeEmptyTask());
            }

            IDataParameter parameter = _dbProviderFactory.CreateParameter();

            parameter.ParameterName = "iPayload";
            parameter.Value         = OraclePayload.ToBytes(messages);

            OracleParameter oracleParameter = parameter as OracleParameter;

            if (oracleParameter != null)
            {
                oracleParameter.OracleDbType = OracleDbType.Blob;
            }

            var operation = _dbOperationFactory.CreateDbOperation(_connectionString, _insertSql, _traceSource, _dbProviderFactory, parameter);

            return(operation.ExecuteNonQueryAsync());
        }