public void Add(object message, IEndpoint endpoint)
 {
     lock (_lock)
     {
         DbSet.Add(new InboundMessage
         {
             MessageId    = _messageKeyProvider.GetKey(message),
             Message      = DefaultSerializer.Serialize(message),
             EndpointName = endpoint.Name,
             Consumed     = DateTime.UtcNow
         });
     }
 }
示例#2
0
        public object Offload(object message, IEndpoint endpoint)
        {
            var messageType = message.GetType();

            if (!MustOffload(messageType))
            {
                return(message);
            }

            var toPublish = new Dictionary <string, object>();
            var toOffload = new Dictionary <string, object>();

            foreach (var prop in messageType.GetProperties())
            {
                if (prop.GetCustomAttribute <OffloadAttribute>() != null)
                {
                    toOffload.Add(prop.Name, prop.GetValue(message));
                }
                else
                {
                    toPublish.Add(prop.Name, prop.GetValue(message));
                }
            }

            _storeWriter.Store(_messageKeyProvider.GetKey(message), endpoint.Serializer.Serialize(toOffload));

            return(toPublish);
        }
示例#3
0
        public async Task Add(object message, IEndpoint endpoint)
        {
            await _semaphore.WaitAsync();

            try
            {
                DbSet.Add(new InboundMessage
                {
                    MessageId    = _messageKeyProvider.GetKey(message),
                    Message      = DefaultSerializer.Serialize(message),
                    EndpointName = endpoint.Name,
                    Consumed     = DateTime.UtcNow
                });
            }
            finally
            {
                _semaphore.Release();
            }
        }
示例#4
0
        private IEnumerable <(object message, byte[] serializedMessage)> GetMessageContentChunks(object message)
        {
            _messageKeyProvider.EnsureKeyIsInitialized(message);

            return(ChunkProducer.ChunkIfNeeded(
                       _messageKeyProvider.GetKey(message, false),
                       message,
                       (Endpoint as IProducerEndpoint)?.Chunk,
                       Endpoint.Serializer));
        }
示例#5
0
 public void Add(object message, IEndpoint endpoint) =>
 Add(new InMemoryInboundLogEntry(_messageKeyProvider.GetKey(message), endpoint.Name));