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 }); } }
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); }
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(); } }
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)); }
public void Add(object message, IEndpoint endpoint) => Add(new InMemoryInboundLogEntry(_messageKeyProvider.GetKey(message), endpoint.Name));