Esempio n. 1
0
        private void ProcessRecord(DbDataReader record, DbOperation dbOperation)
#endif
        {
            var             id      = record.GetInt64(0);
            ScaleoutMessage message = SqlPayload.FromBytes(record);

            _logger.LogDebug(String.Format("{0}SqlReceiver last payload ID={1}, new payload ID={2}", _loggerPrefix, _lastPayloadId, id));

            if (id > _lastPayloadId + 1)
            {
                _logger.LogError(String.Format("{0}Missed message(s) from SQL Server. Expected payload ID {1} but got {2}.", _loggerPrefix, _lastPayloadId + 1, id));
            }
            else if (id <= _lastPayloadId)
            {
                _logger.LogInformation(String.Format("{0}Duplicate message(s) or payload ID reset from SQL Server. Last payload ID {1}, this payload ID {2}", _loggerPrefix, _lastPayloadId, id));
            }

            _lastPayloadId = id;

            // Update the Parameter with the new payload ID
            dbOperation.Parameters[0].Value = _lastPayloadId;

            _logger.LogDebug(String.Format("{0}Updated receive reader initial payload ID parameter={1}", _loggerPrefix, _dbOperation.Parameters[0].Value));

            _logger.LogDebug(String.Format("{0}Payload {1} containing {2} message(s) received", _loggerPrefix, id, message.Messages.Count));

            Received((ulong)id, message);
        }
Esempio n. 2
0
        public Task Send(IList <Message> messages)
        {
            if (messages == null || messages.Count == 0)
            {
                return(Task.FromResult <object>(null));
            }

            var parameter = _dbProviderFactory.CreateParameter();

            parameter.ParameterName = "Payload";
            parameter.DbType        = DbType.Binary;
            parameter.Value         = SqlPayload.ToBytes(messages);

            var operation = new DbOperation(_connectionString, _insertDml, _logger, parameter);

            return(operation.ExecuteNonQueryAsync());
        }