/// <summary> /// Initializes a new instance of the <see cref="SaveMetaDataCommand" /> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="metaData">The meta data.</param> public SaveMetaDataCommand(RedisQueueId id, RedisMetaData metaData) { Guard.NotNull(() => id, id); Guard.NotNull(() => metaData, metaData); Id = id; MetaData = metaData; }
/// <summary> /// Sends an expired message. /// </summary> /// <param name="commandSend">The command send.</param> /// <param name="expireTime">The expire time.</param> /// <returns></returns> /// <exception cref="DotNetWorkQueueException">Failed to enqueue a record. The LUA enqueue script returned null</exception> private async Task <string> SendExpirationMessageAsync(SendMessageCommand commandSend, long expireTime) { var id = commandSend.MessageToSend.GetInternalHeader(_headers.StandardHeaders.RpcResponseId); var rpc = false; var messageId = _messageIdFactory.Create().Create().ToString(); if (!string.IsNullOrWhiteSpace(id)) { messageId = id; rpc = true; } var meta = new RedisMetaData(_unixTimeFactory.Create().GetCurrentUnixTimestampMilliseconds()); var serialized = _serializer.Serializer.MessageToBytes(new MessageBody { Body = commandSend.MessageToSend.Body }); commandSend.MessageToSend.SetHeader(_headers.StandardHeaders.MessageInterceptorGraph, serialized.Graph); var result = await _enqueueExpirationLua.ExecuteAsync(messageId, serialized.Output, _serializer.InternalSerializer.ConvertToBytes(commandSend.MessageToSend.Headers), _serializer.InternalSerializer.ConvertToBytes(meta), expireTime, rpc, commandSend.MessageData.Route).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(result)) { throw new DotNetWorkQueueException("Failed to enqueue a record. The LUA enqueue script returned null"); } messageId = result; return(messageId); }
/// <summary> /// Sends the standard message. /// </summary> /// <param name="commandSend">The command send.</param> /// <returns></returns> /// <exception cref="DotNetWorkQueueException">Failed to enqueue a record. The LUA enqueue script returned null</exception> private async Task <string> SendStandardMessageAsync(SendMessageCommand commandSend) { var messageId = _messageIdFactory.Create().Create().ToString(); var meta = new RedisMetaData(_unixTimeFactory.Create().GetCurrentUnixTimestampMilliseconds()); var serialized = _serializer.Serializer.MessageToBytes(new MessageBody { Body = commandSend.MessageToSend.Body }, commandSend.MessageToSend.Headers); commandSend.MessageToSend.SetHeader(_headers.StandardHeaders.MessageInterceptorGraph, serialized.Graph); var jobName = _jobSchedulerMetaData.GetJobName(commandSend.MessageData); var scheduledTime = DateTimeOffset.MinValue; var eventTime = DateTimeOffset.MinValue; if (!string.IsNullOrWhiteSpace(jobName)) { scheduledTime = _jobSchedulerMetaData.GetScheduledTime(commandSend.MessageData); eventTime = _jobSchedulerMetaData.GetEventTime(commandSend.MessageData); } var result = await _enqueueLua.ExecuteAsync(messageId, serialized.Output, _serializer.InternalSerializer.ConvertToBytes(commandSend.MessageToSend.Headers), _serializer.InternalSerializer.ConvertToBytes(meta), jobName, scheduledTime, eventTime, commandSend.MessageData.Route).ConfigureAwait(false); if (string.IsNullOrWhiteSpace(result)) { throw new DotNetWorkQueueException("Failed to enqueue a record. The LUA enqueue script returned null"); } messageId = result; return(messageId); }
public void Create_Default() { var test = new RedisMetaData(1000); Assert.Equal(1000, test.QueueDateTime); Assert.NotNull(test.ErrorTracking); }
public void Create_Default(string number, int metaNumber) { var id = new RedisQueueId(number); var meta = new RedisMetaData(metaNumber); var test = new SaveMetaDataCommand(id, meta); Assert.Equal(id, test.Id); Assert.Equal(meta, test.MetaData); }
/// <summary> /// Sends an expired message. /// </summary> /// <param name="commandSend">The command send.</param> /// <param name="expireTime">The expire time.</param> /// <returns></returns> /// <exception cref="DotNetWorkQueueException">Failed to enqueue a record. The LUA enqueue script returned null</exception> private string SendExpirationMessage(SendMessageCommand commandSend, long expireTime) { var messageId = _messageIdFactory.Create().Create().ToString(); var meta = new RedisMetaData(_unixTimeFactory.Create().GetCurrentUnixTimestampMilliseconds()); var serialized = _serializer.Serializer.MessageToBytes(new MessageBody { Body = commandSend.MessageToSend.Body }, commandSend.MessageToSend.Headers); commandSend.MessageToSend.SetHeader(_headers.StandardHeaders.MessageInterceptorGraph, serialized.Graph); var result = _enqueueExpirationLua.Execute(messageId, serialized.Output, _serializer.InternalSerializer.ConvertToBytes(commandSend.MessageToSend.Headers), _serializer.InternalSerializer.ConvertToBytes(meta), expireTime, commandSend.MessageData.Route); if (string.IsNullOrWhiteSpace(result)) { throw new DotNetWorkQueueException("Failed to enqueue a record. The LUA enqueue script returned null"); } messageId = result; return(messageId); }