private TopicMessage BuildCommandMessage(ICommand command, bool needReply, string sagaIdCommandItemKey) { var delayedCommand = command as DelayedCommand; var realCommand = delayedCommand == null ? command : delayedCommand.GetWrappedCommand(); Ensure.NotNull(realCommand.AggregateRootId, "aggregateRootId"); var commandData = _jsonSerializer.Serialize(realCommand); var topic = _commandTopicProvider.GetTopic(realCommand); var replyAddress = needReply && _commandResultProcessor != null?_commandResultProcessor.BindingAddress.ToString() : null; var sagaId = realCommand.Items != null && realCommand.Items.ContainsKey(sagaIdCommandItemKey) ? realCommand.Items[sagaIdCommandItemKey] : null; var messageData = _jsonSerializer.Serialize(new CommandMessage { CommandData = commandData, ReplyAddress = replyAddress, SagaId = string.IsNullOrEmpty(sagaId) ? null : sagaId }); return(new TopicMessage( topic, (int)MessageTypeCode.CommandMessage, Encoding.UTF8.GetBytes(messageData), "text/json", delayedCommand == null ? 0 : delayedCommand.DelayedMilliseconds, _typeNameProvider.GetTypeName(realCommand.GetType()))); }
private EQueueMessage CreateEQueueMessage(DomainEventStreamMessage eventStream) { var eventMessage = CreateEventMessage(eventStream); var topic = _eventTopicProvider.GetTopic(eventStream.Events.First()); var data = _jsonSerializer.Serialize(eventMessage); return(new EQueueMessage(topic, (int)EQueueMessageTypeCode.DomainEventStreamMessage, Encoding.UTF8.GetBytes(data))); }
private EQueueMessage CreateEQueueMessage(IApplicationMessage message) { var messageTypeCode = _messageTypeCodeProvider.GetTypeCode(message.GetType()); var topic = _messageTopicProvider.GetTopic(message); var data = _jsonSerializer.Serialize(message); return(new EQueueMessage(topic, messageTypeCode, Encoding.UTF8.GetBytes(data))); }
private ENodeMessage CreateENodeMessage(DomainEventStreamMessage eventStream) { Ensure.NotNull(eventStream.AggregateRootId, "aggregateRootId"); var eventMessage = CreateEventMessage(eventStream); var topic = _eventTopicProvider.GetTopic(eventStream.Events.First()); var data = _jsonSerializer.Serialize(eventMessage); return(new ENodeMessage(topic, (int)ENodeMessageTypeCode.DomainEventStreamMessage, data)); }
private TopicMessage CreateTopicMessage(DomainEventStreamMessage eventStream) { Ensure.NotNull(eventStream.AggregateRootId, "aggregateRootId"); var eventMessage = CreateEventMessage(eventStream); var topic = _eventTopicProvider.GetTopic(eventStream.Events.First()); var data = _jsonSerializer.Serialize(eventMessage); return(new TopicMessage(topic, (int)MessageTypeCode.DomainEventStreamMessage, Encoding.UTF8.GetBytes(data), "text/json")); }
public Task PublishAsync(DomainEventStreamMessage eventStream) { Ensure.NotNull(eventStream.AggregateRootId, "aggregateRootId"); var eventMessage = CreateEventMessage(eventStream); var topic = _eventTopicProvider.GetTopic(eventStream.Events.First()); var data = _jsonSerializer.Serialize(eventMessage); var equeueMessage = new EQueueMessage(topic, (int)EQueueMessageTypeCode.DomainEventStreamMessage, Encoding.UTF8.GetBytes(data)); return(_sendMessageService.SendMessageAsync(Producer, "events", string.Join(",", eventStream.Events.Select(x => x.GetType().Name)), equeueMessage, data, eventStream.AggregateRootId, eventStream.Id, eventStream.Items)); }
private ENodeMessage CreateENodeMessage(IApplicationMessage message) { var topic = _messageTopicProvider.GetTopic(message); var data = _jsonSerializer.Serialize(message); return(new ENodeMessage( topic, (int)ENodeMessageTypeCode.ApplicationMessage, data, _typeNameProvider.GetTypeName(message.GetType()))); }
public Task PublishAsync(IApplicationMessage message) { var topic = _messageTopicProvider.GetTopic(message); var data = _jsonSerializer.Serialize(message); var equeueMessage = new EQueueMessage( topic, (int)EQueueMessageTypeCode.ApplicationMessage, Encoding.UTF8.GetBytes(data), _typeNameProvider.GetTypeName(message.GetType())); return(_sendMessageService.SendMessageAsync(Producer, "applicationMessage", message.GetType().Name, equeueMessage, data, message.Id, message.Id, message.Items)); }
private TopicMessage CreateTopicMessage(IApplicationMessage message) { var topic = _messageTopicProvider.GetTopic(message); var data = _jsonSerializer.Serialize(message); return(new TopicMessage( topic, (int)MessageTypeCode.ApplicationMessage, Encoding.UTF8.GetBytes(data), "text/json", _typeNameProvider.GetTypeName(message.GetType()))); }
private TopicMessage CreateTopicMessage(IDomainException exception) { var topic = _exceptionTopicProvider.GetTopic(exception); var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var data = _jsonSerializer.Serialize(new DomainExceptionMessage { UniqueId = exception.Id, Timestamp = exception.Timestamp, Items = exception.Items, SerializableInfo = serializableInfo }); return(new TopicMessage(topic, (int)MessageTypeCode.ExceptionMessage, Encoding.UTF8.GetBytes(data), "text/json", _typeNameProvider.GetTypeName(exception.GetType()))); }
private EQueueMessage BuildCommandMessage(ICommand command) { var commandData = _jsonSerializer.Serialize(command); var topic = _commandTopicProvider.GetTopic(command); var commandTypeCode = _commandTypeCodeProvider.GetTypeCode(command.GetType()); var replyAddress = _commandResultProcessor != null?_commandResultProcessor.BindingAddress.ToString() : null; var messageData = _jsonSerializer.Serialize(new CommandMessage { CommandTypeCode = commandTypeCode, CommandData = commandData, ReplyAddress = replyAddress }); return(new EQueueMessage(topic, (int)EQueueMessageTypeCode.CommandMessage, Encoding.UTF8.GetBytes(messageData))); }
private EQueueMessage BuildCommandMessage(ICommand command) { var commandData = _jsonSerializer.Serialize(command); var topic = _commandTopicProvider.GetTopic(command); var commandTypeCode = _commandTypeCodeProvider.GetTypeCode(command.GetType()); var commandExecutedMessageTopic = _commandResultProcessor != null ? _commandResultProcessor.CommandExecutedMessageTopic : CommandExecutedMessageTopic; var domainEventHandledMessageTopic = _commandResultProcessor != null ? _commandResultProcessor.DomainEventHandledMessageTopic : DomainEventHandledMessageTopic; var messageData = _jsonSerializer.Serialize(new CommandMessage { CommandTypeCode = commandTypeCode, CommandData = commandData, CommandExecutedMessageTopic = commandExecutedMessageTopic, DomainEventHandledMessageTopic = domainEventHandledMessageTopic }); return(new EQueueMessage(topic, (int)EQueueMessageTypeCode.CommandMessage, Encoding.UTF8.GetBytes(messageData))); }
private ENodeMessage BuildCommandMessage(ICommand command, bool needReply = false) { Ensure.NotNull(command.AggregateRootId, "aggregateRootId"); var commandData = _jsonSerializer.Serialize(command); var topic = _commandTopicProvider.GetTopic(command); var replyAddress = needReply && _commandResultProcessor != null ? _commandResultProcessor.BindingServerAddress : null; var messageData = _jsonSerializer.Serialize(new CommandMessage { CommandData = commandData, ReplyAddress = replyAddress }); return(new ENodeMessage( topic, (int)ENodeMessageTypeCode.CommandMessage, messageData, _typeNameProvider.GetTypeName(command.GetType()))); }
private EQueueMessage CreateEQueueMessage(IPublishableException exception) { var topic = _exceptionTopicProvider.GetTopic(exception); var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var data = _jsonSerializer.Serialize(new PublishableExceptionMessage { UniqueId = exception.Id, Timestamp = exception.Timestamp, SerializableInfo = serializableInfo }); return(new EQueueMessage( topic, (int)EQueueMessageTypeCode.ExceptionMessage, Encoding.UTF8.GetBytes(data), _typeNameProvider.GetTypeName(exception.GetType()))); }
private EQueueMessage BuildCommandMessage(ICommand command, bool needReply = false) { Ensure.NotNull(command.AggregateRootId, "aggregateRootId"); var commandData = _jsonSerializer.Serialize(command); var topic = _commandTopicProvider.GetTopic(command); var replyAddress = needReply && _commandResultProcessor != null?_commandResultProcessor.BindingAddress.ToString() : null; var messageData = _jsonSerializer.Serialize(new CommandMessage { CommandData = commandData, ReplyAddress = replyAddress }); return(new EQueueMessage( topic: topic, code: (int)EQueueMessageTypeCode.CommandMessage, body: Encoding.UTF8.GetBytes(messageData), tag: _typeNameProvider.GetTypeName(command.GetType()))); }
private EQueueMessage CreateEQueueMessage(IPublishableException exception) { var exceptionTypeCode = _exceptionTypeCodeProvider.GetTypeCode(exception.GetType()); var topic = _exceptionTopicProvider.GetTopic(exception); var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var sequenceMessage = exception as ISequenceMessage; var data = _jsonSerializer.Serialize(new PublishableExceptionMessage { UniqueId = exception.Id, AggregateRootTypeCode = sequenceMessage != null ? sequenceMessage.AggregateRootTypeCode : 0, AggregateRootId = sequenceMessage != null ? sequenceMessage.AggregateRootId : null, Timestamp = exception.Timestamp, ExceptionTypeCode = exceptionTypeCode, SerializableInfo = serializableInfo }); return(new EQueueMessage(topic, (int)EQueueMessageTypeCode.ExceptionMessage, Encoding.UTF8.GetBytes(data))); }
public Task PublishAsync(IDomainException exception) { var topic = _exceptionTopicProvider.GetTopic(exception); var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var data = _jsonSerializer.Serialize(new DomainExceptionMessage { UniqueId = exception.Id, Timestamp = exception.Timestamp, Items = exception.Items, SerializableInfo = serializableInfo }); var equeueMessage = new EQueueMessage( topic, (int)EQueueMessageTypeCode.ExceptionMessage, Encoding.UTF8.GetBytes(data), _typeNameProvider.GetTypeName(exception.GetType())); return(_sendMessageService.SendMessageAsync(Producer, "exception", exception.GetType().Name, equeueMessage, data, exception.Id, exception.Id, exception.Items)); }
private ENodeMessage CreateENodeMessage(IPublishableException exception) { var topic = _exceptionTopicProvider.GetTopic(exception); var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var sequenceMessage = exception as ISequenceMessage; var data = _jsonSerializer.Serialize(new PublishableExceptionMessage { UniqueId = exception.Id, AggregateRootTypeName = sequenceMessage != null ? sequenceMessage.AggregateRootTypeName : null, AggregateRootId = sequenceMessage != null ? sequenceMessage.AggregateRootStringId : null, Timestamp = exception.Timestamp, SerializableInfo = serializableInfo }); return(new ENodeMessage( topic, (int)ENodeMessageTypeCode.ExceptionMessage, data, _typeNameProvider.GetTypeName(exception.GetType()))); }
protected KafkaReceiver(ITextSerializer serializer, ITopicProvider topicProvider) { _serializer = serializer; _decoder = new DefaultDecoder(); _topic = topicProvider.GetTopic(typeof(TDescriptor)); }
public KafkaSender(ITextSerializer serializer, ITopicProvider topicProvider) { _serializer = serializer; _kind = typeof(TMessage).FullName.Substring(1); _topic = topicProvider.GetTopic(typeof(TDescriptor)); }