示例#1
0
        /// <inheritdoc />
        public async Task <TransportMessage> Receive(ITransactionContext context, CancellationToken cancellationToken)
        {
            using (await _receiveBottleneck.Enter(cancellationToken))
            {
                var connection = context.GetConnection(_factory);

                using (var selectCommand = connection.CreateCommand())
                {
                    selectCommand.CommandText = _receiveSql;
                    selectCommand.CommandType = CommandType.StoredProcedure;
                    selectCommand.Parameters.Add("recipientQueue", Address);
                    selectCommand.Parameters.Add("now", _rebusTime.Now.ToOracleTimeStamp());
                    selectCommand.Parameters.Add("output", OracleDbType.RefCursor, ParameterDirection.Output);
                    selectCommand.InitialLOBFetchSize = -1;
                    selectCommand.ExecuteNonQuery();

                    using (var reader = (selectCommand.Parameters["output"].Value as OracleRefCursor).GetDataReader())
                    {
                        if (!reader.Read())
                        {
                            return(null);
                        }

                        var headers           = (byte[])reader["headers"];
                        var body              = (byte[])reader["body"];
                        var headersDictionary = HeaderSerializer.Deserialize(headers);
                        return(new TransportMessage(headersDictionary, body));
                    }
                }
            }
        }
 public static OracleCommand GetSendCommand(this ITransactionContext context, OracleFactory factory, string sql)
 {
     return(context.GetOrAdd(SendCommandKey, () =>
     {
         var connection = context.GetConnection(factory);
         var command = SendCommand.Create(connection, sql);
         context.OnDisposed(command.Dispose);
         return command;
     }));
 }