public void Add(Type type, IMessageConvention convention) { if (_conventions.ContainsKey(type)) { _conventions[type] = convention; } else { _conventions.Add(type, convention); } }
public void Send( object message, IMessageConvention convention, string messageId = null, string correlationId = null, string spanContext = null, IDictionary <string, object> headers = null) { if (message is null) { if (_isLoggerEnabled) { _logger.LogWarning("Cannot null message via convention: {Convention}", convention); } return; } var threadId = Thread.CurrentThread.ManagedThreadId; if (!_channels.TryGetValue(threadId, out var channel)) { if (_channelsCount >= _maxChannels) { throw new InvalidOperationException( $"Cannot create new channel, limit reached. Got {_channelsCount} of {_maxChannels} possible"); } channel = _connection.CreateModel(); _channels.TryAdd(threadId, channel); Interlocked.Increment(ref _channelsCount); _logger.LogTrace( $"Created a channel for thread: {threadId}, total channels: {_channelsCount}/{_maxChannels}"); } var messageBody = _serializer.SerializeBinary(message); var channelProps = GetBasicProperties(channel, messageId, correlationId, spanContext, headers); channel.BasicPublish(convention.Exchange, convention.Route, channelProps, messageBody); }
internal void Add(IMessageConvention messageConvention) { conventions.Add(messageConvention); }
public void Add <T>(IMessageConvention convention) => Add(typeof(T), convention);
public static void Add(this Conventions conventions, IMessageConvention convention) { var addMethod = typeof(Conventions).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic); addMethod.Invoke(conventions, new object[] { convention }); }
public OverridableMessageConvention(IMessageConvention inner) { this.inner = inner; }
/// <summary> /// Adds a message convention that will be used to evaluate whether a type is a message, command, or event. /// </summary> public ConventionsBuilder Add(IMessageConvention messageConvention) { Guard.AgainstNull(nameof(messageConvention), messageConvention); Conventions.Add(messageConvention); return(this); }