internal MessagePublisher(IMessagingEntityFactory messagingEntityFactory, IMessageSerializer serializer, IMessagePropertyProvider <TMessage> propertyProvider, IMessageOutgoingPropertiesTable messageOutgoingPropertiesTable) { if (messagingEntityFactory == null) { throw new ArgumentNullException(nameof(messagingEntityFactory)); } if (serializer == null) { throw new ArgumentNullException(nameof(serializer)); } if (propertyProvider == null) { throw new ArgumentNullException(nameof(propertyProvider)); } if (messageOutgoingPropertiesTable == null) { throw new ArgumentNullException(nameof(messageOutgoingPropertiesTable)); } _messagingEntityFactory = messagingEntityFactory; _serializer = serializer; _propertyProvider = propertyProvider; _messageOutgoingPropertiesTable = messageOutgoingPropertiesTable; _messageTypeMessageSenderMap = new ConcurrentDictionary <Type, IMessageSender>(); }
public void Add <T>(IMessagePropertyProvider <T> messagePropertyProvider) where T : class, TMessage { List <object> propertyProvidersForType; Type messageType = typeof(T); if (!_messagePropertyProviders.TryGetValue(messageType, out propertyProvidersForType)) { propertyProvidersForType = new List <object>(); _messagePropertyProviders.Add(messageType, propertyProvidersForType); } propertyProvidersForType.Add(messagePropertyProvider); }
public void SetUp() { A.Fake<IConnectionFactory>(); _connection = A.Fake<IConnection>(); _lazyConnection = new Lazy<IConnection>(() => { _connection.Start(); return _connection; }); _session = A.Fake<ISession>(); _producer = A.Fake<IMessageProducer>(); _serializer = A.Fake<IMessageSerializer>(); _destination = A.Fake<IDestination>(); _message = A.Fake<IBytesMessage>(); _messagePropertyProvider = A.Fake<IMessagePropertyProvider<IMessage>>(); A.CallTo(() => _connection.CreateSession(A<Apache.NMS.AcknowledgementMode>.Ignored)).Returns(_session); A.CallTo(() => _session.CreateProducer(_destination)).Returns(_producer); A.CallTo(() => _producer.CreateBytesMessage()).Returns(_message); _publisher = new MessagePublisher<IMessage>(_lazyConnection, _destination, _serializer, _messagePropertyProvider, _testScheduler); }
public void SetUp() { A.Fake <IConnectionFactory>(); _connection = A.Fake <IConnection>(); _lazyConnection = new Lazy <IConnection>(() => { _connection.Start(); return(_connection); }); _session = A.Fake <ISession>(); _producer = A.Fake <IMessageProducer>(); _serializer = A.Fake <IMessageSerializer>(); _destination = A.Fake <IDestination>(); _message = A.Fake <ITextMessage>(); _messagePropertyProvider = A.Fake <IMessagePropertyProvider <IMessage> >(); A.CallTo(() => _connection.CreateSession(A <Apache.NMS.AcknowledgementMode> .Ignored)).Returns(_session); A.CallTo(() => _session.CreateProducer(_destination)).Returns(_producer); A.CallTo(() => _session.CreateTextMessage(A <string> ._)).Returns(_message); A.CallTo(() => _serializer.Serialize(A <object> ._)).Returns("SerializedString"); _testScheduler = new TestScheduler(); _publisher = new MessagePublisher <IMessage>(_lazyConnection, _destination, _serializer, _messagePropertyProvider, _testScheduler); }
public ICanSpecifyPropertyProviders <TMessage, TCommand, TEvent, TRequest, TResponse> UsingMessagePropertyProviderFor <T>(IMessagePropertyProvider <T> messagePropertyProvider) where T : class, TMessage { if (messagePropertyProvider == null) { throw new ArgumentNullException("provider"); } if (!typeof(TServiceMessage).IsAssignableFrom(typeof(T))) { throw new ArgumentException(string.Format("{0} is not a subclass of {1}.", typeof(T).FullName, typeof(TServiceMessage).FullName), "messagePropertyProvider"); } _messagePropertyProviderManager.Add(messagePropertyProvider); return(this); }