Ejemplo n.º 1
0
        public void SetMessageGroupCount(Guid groupId, int messageCount, SimpleMessage andThen)
        {
            var db = _redis.GetDatabase();
            var messageGroupHashKey = RedisTaskMultiplexorConstants.MessageGroupHashKeyPrefix + groupId;

            db.HashSet(messageGroupHashKey, new HashEntry[]
            {
                new HashEntry("MsgCount", messageCount),
                new HashEntry("Handled", 0),
                new HashEntry("Prepared", DateTime.UtcNow.ToRedisValue()),
                new HashEntry("AndThen", StaticRedisSerializer.RedisSerialize(andThen)),
            });
        }
Ejemplo n.º 2
0
        //todo: add poll MessageGroupQueue
        // if completed, delete straight away
        // if last message handled, deliver and then delete
        // if no message deleted or handled, delete after 1 hour

        private void LastMessageHandled(Guid groupId)
        {
            var db = _redis.GetDatabase();
            var messageGroupHashKey = RedisTaskMultiplexorConstants.MessageGroupHashKeyPrefix + groupId;
            var completed           = db.HashGet(messageGroupHashKey, "Completed");

            if (completed.HasValue)
            {
                return;
            }
            var andThen    = db.HashGet(messageGroupHashKey, "AndThen");
            var andThenObj = StaticRedisSerializer.RedisDeserialize <SimpleMessage>(andThen);

            _andThenMessageDeliverer.Deliver(andThenObj);
            db.HashSet(messageGroupHashKey, "Completed", DateTime.UtcNow.ToRedisValue());
        }