Example #1
0
 public QueueMonitor(IMessageReader reader, IMessageConverter converter, MessageValidator validator, IValidationOutput output)
 {
     _reader = reader;
     _converter = converter;
     _validator = validator;
     _output = output;
 }
Example #2
0
 public Receiver(IWorker <TMessage> worker, IChannelFactory channelFactory, IMessageConverter messageConverter, string broker, string endpoint)
     : base(channelFactory, messageConverter, broker, endpoint)
 {
     _worker           = worker ?? throw new ArgumentException(nameof(worker));
     worker.JobDone   += Worker_JobDone;
     worker.JobFailed += Worker_JobFailed;
     _consumer         = new EventingBasicConsumer(_channel.Model);
 }
Example #3
0
 protected ReceivingLinkHandler(IReceivingAmqpLink link, Uri requestUri, IDictionary <string, string> boundVariables,
                                IMessageConverter <AmqpMessage> messageConverter)
     : base(link, requestUri, boundVariables, messageConverter)
 {
     Preconditions.CheckArgument(link.IsReceiver, $"Link {requestUri} cannot receive");
     this.ReceivingLink        = link;
     this.sendMessageProcessor = new ActionBlock <AmqpMessage>(s => this.ProcessMessageAsync(s));
 }
 public ServiceFabricSourceFactory(IReliableStateManager stateManager, Guid partitionId,
                                   String sourceName, IMessageConverter messageConverter)
 {
     this.stateManager     = stateManager;
     this.partitionId      = partitionId;
     this.sourceName       = sourceName;
     this.messageConverter = messageConverter;
 }
Example #5
0
            public CloudReceiver(CloudProxy cloudProxy, ICloudListener cloudListener)
            {
                this.cloudProxy    = Preconditions.CheckNotNull(cloudProxy, nameof(cloudProxy));
                this.cloudListener = Preconditions.CheckNotNull(cloudListener, nameof(cloudListener));
                IMessageConverter <TwinCollection> converter = cloudProxy.messageConverterProvider.Get <TwinCollection>();

                this.desiredUpdateHandler = new DesiredPropertyUpdateHandler(cloudListener, converter, cloudProxy);
            }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="messageQueue">The MSMQ message queue from which
        /// messages will be read.</param>
        /// <param name="messageConverter">A message converter for mapping
        /// MSMQ messages to NMS messages.</param>
        public AbstractMessageReader(MessageQueue messageQueue,
                                     IMessageConverter messageConverter)
        {
            this.messageQueue = messageQueue;

            this.messageConverter   = messageConverter;
            this.messageConverterEx = (messageConverter as IMessageConverterEx);
        }
Example #7
0
 public MemoryService(IOptions <AppConfig> config, IMemoryConfigValidator memoryConfigValidator, IMessageConverter messageConverter, IMemoryInfo memoryInfo, IMessageQueueService messageQueue, ILogger <MemoryService> logger)
 {
     this.config = config;
     this.memoryConfigValidator = memoryConfigValidator;
     this.messageConverter      = messageConverter;
     this.memoryInfo            = memoryInfo;
     this.messageQueue          = messageQueue;
     this.logger = logger;
 }
Example #8
0
 public TwinReceivingLinkHandler(
     IIdentity identity,
     IReceivingAmqpLink link,
     Uri requestUri,
     IDictionary <string, string> boundVariables, IConnectionHandler connectionHandler,
     IMessageConverter <AmqpMessage> messageConverter)
     : base(identity, link, requestUri, boundVariables, connectionHandler, messageConverter)
 {
 }
Example #9
0
 public MessageStore(
     IMessageStorageProvider storageProvider,
     IMessageHasher messageHasher,
     IMessageConverter messageConverter)
 {
     _storageProvider  = storageProvider;
     _messageHasher    = messageHasher;
     _messageConverter = messageConverter;
 }
Example #10
0
 public CloudSync(
     IConnectionManager connectionManager,
     IMessageConverter <TwinCollection> twinCollectionConverter,
     IMessageConverter <Twin> twinConverter)
 {
     this.connectionManager       = connectionManager;
     this.twinCollectionConverter = twinCollectionConverter;
     this.twinConverter           = twinConverter;
 }
Example #11
0
 public DeviceProxy(IMessagingChannel <IProtocolGatewayMessage> channel, IIdentity identity,
                    IMessageConverter <IProtocolGatewayMessage> messageConverter, IByteBufferConverter byteBufferConverter)
 {
     this.isActive            = new AtomicBoolean(true);
     this.channel             = Preconditions.CheckNotNull(channel, nameof(channel));
     this.messageConverter    = Preconditions.CheckNotNull(messageConverter, nameof(messageConverter));
     this.Identity            = Preconditions.CheckNotNull(identity, nameof(this.Identity));
     this.byteBufferConverter = Preconditions.CheckNotNull(byteBufferConverter, nameof(byteBufferConverter));
 }
 public DiskDriveService(IOptions <AppConfig> config, IDiskDriveConfigValidator diskDriveConfigValidator, IMessageConverter messageConverter, IDiskDriveInfo diskDriveInfo, IMessageQueueService messageQueueService, ILogger <DiskDriveService> logger)
 {
     this.config = config;
     this.diskDriveConfigValidator = diskDriveConfigValidator;
     this.messageConverter         = messageConverter;
     this.diskDriveInfo            = diskDriveInfo;
     this.messageQueueService      = messageQueueService;
     this.logger = logger;
 }
Example #13
0
        protected virtual IMessageBuilder BuildReply(IMessageConverter converter, IMessage amqpReplyMessage)
        {
            var replyObject = converter.FromMessage(amqpReplyMessage, null);
            var builder     = PrepareMessageBuilder(replyObject);

            // var headers = getHeaderMapper().toHeadersFromReply(amqpReplyMessage.getMessageProperties());
            builder.CopyHeadersIfAbsent(amqpReplyMessage.Headers);
            return(builder);
        }
Example #14
0
 public DesiredPropertyUpdateHandler(
     ICloudListener listener,
     IMessageConverter <TwinCollection> converter,
     CloudProxy cloudProxy)
 {
     this.listener   = listener;
     this.converter  = converter;
     this.cloudProxy = cloudProxy;
 }
Example #15
0
        public async Task <IMessage> GetTwinAsync()
        {
            Twin twin = await this.client.GetTwinAsync();

            Events.GetTwin(this);
            IMessageConverter <Twin> converter = this.messageConverterProvider.Get <Twin>();

            return(converter.ToMessage(twin));
        }
Example #16
0
 /**
  * Map an o.s.m.Message to an o.s.a.core.Message. When using a
  * {@link ContentTypeDelegatingMessageConverter}, {@link AmqpHeaders#CONTENT_TYPE} and
  * {@link MessageHeaders#CONTENT_TYPE} will be used for the selection, with the AMQP
  * header taking precedence.
  * @param requestMessage the request message.
  * @param converter the message converter to use.
  * @param headerMapper the header mapper to use.
  * @param defaultDeliveryMode the default delivery mode.
  * @param headersMappedLast true if headers are mapped after conversion.
  * @return the mapped Message.
  */
 public static IMessage MapMessage(
     IMessage requestMessage,
     IMessageConverter converter,
     IRabbitHeaderMapper headerMapper,
     MessageDeliveryMode defaultDeliveryMode,
     bool headersMappedLast)
 {
     return(DoMapMessage(requestMessage, converter, headerMapper, defaultDeliveryMode, headersMappedLast, false));
 }
 public FacebookMessengerController(IFacebookRepository repository,
                                    IMessageConverter <FacebookMessage> converter,
                                    IFacebookMessengerVerifier verifier,
                                    IConfiguration configuration)
 {
     _facebookRepository = repository;
     _messageConverter   = converter;
     _verifier           = verifier;
     _configuration      = configuration;
 }
 private static MessageStatus GetMessageStatus(IMessageConverter converter, DataSourceOperationException dataSourceOperationException)
 {
     if (dataSourceOperationException is ADInvalidCredentialException)
     {
         ADTransientException unavailableException = new ADTransientException(dataSourceOperationException.LocalizedString, dataSourceOperationException);
         return(StorageExceptionHandler.GetMessageStatus(converter, unavailableException));
     }
     StorageExceptionHandler.LogException(converter, dataSourceOperationException);
     return(new MessageStatus(MessageAction.NDR, StorageExceptionHandler.GetExceptionSmtpResponse(converter, dataSourceOperationException, true), dataSourceOperationException));
 }
 internal static void LogException(IMessageConverter converter, Exception e)
 {
     TraceHelper.TracePass(StorageExceptionHandler.diag, 0L, "Exception occurred during message {0} : {1}", new object[]
     {
         converter.Description,
         e
     });
     converter.LogMessage(e);
     StorageExceptionHandler.exceptionCounter.IncrementCounter(e.GetType().FullName);
 }
Example #20
0
 public RPCClient(IChannelFactory channelFactory, IMessageConverter messageConverter, string broker, string endpoint) :
     base(channelFactory, messageConverter, broker, endpoint)
 {
     _replyQueueName     = _channel.Model.QueueDeclare().QueueName;
     _consumer           = new EventingBasicConsumer(_channel.Model);
     _consumer.Received += _consumer_Received;
     _channel.Model.BasicConsume(queue: _replyQueueName,
                                 autoAck: true,
                                 consumer: _consumer);
 }
 protected override void ConfigureMessageConverter(NmsTemplate nmsTemplate, INmsHeaderMapper headerMapper)
 {
     IMessageConverter converter = nmsTemplate.MessageConverter;
     if (converter == null || !(converter is HeaderMappingMessageConverter))
     {
         HeaderMappingMessageConverter hmmc = new HeaderMappingMessageConverter(converter, headerMapper);
         hmmc.ExtractIntegrationMessagePayload = extractPayload;
         nmsTemplate.MessageConverter = hmmc;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureServiceBus"/> class.
        /// </summary>
        /// <param name="messageConverter">The message converter.</param>
        /// <param name="configuration">The configuration of planning poker for Azure platform.</param>
        public AzureServiceBus(IMessageConverter messageConverter, IAzurePlanningPokerConfiguration configuration)
        {
            if (messageConverter == null)
            {
                throw new ArgumentNullException("messageConverter");
            }

            this.MessageConverter = messageConverter;
            this.Configuration    = configuration ?? new AzurePlanningPokerConfigurationElement();
        }
Example #23
0
 public TwinManager(IConnectionManager connectionManager, IMessageConverter <TwinCollection> twinCollectionConverter, IMessageConverter <Twin> twinConverter, Option <IEntityStore <string, TwinInfo> > twinStore)
 {
     this.connectionManager       = Preconditions.CheckNotNull(connectionManager, nameof(connectionManager));
     this.twinCollectionConverter = Preconditions.CheckNotNull(twinCollectionConverter, nameof(twinCollectionConverter));
     this.twinConverter           = Preconditions.CheckNotNull(twinConverter, nameof(twinConverter));
     this.TwinStore = Preconditions.CheckNotNull(twinStore, nameof(twinStore));
     this.reportedPropertiesLock = new AsyncLock();
     this.twinLock    = new AsyncLock();
     this.actionBlock = new ActionBlock <IIdentity>(this.ProcessConnectionEstablishedForDevice);
 }
Example #24
0
        /// <summary>
        /// Extract the message body from the given message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>the content of the message, to be passed into the
        /// listener method as argument</returns>
        /// <exception cref="EMSException">if thrown by EMS API methods</exception>
        private object ExtractMessage(Message message)
        {
            IMessageConverter converter = MessageConverter;

            if (converter != null)
            {
                return(converter.FromMessage(message));
            }
            return(message);
        }
        /// <summary>
        /// Extracts the message body from the given message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>the content of the message, to be passed into the
        /// listener method as argument</returns>
        protected virtual object ExtractMessage(Message message)
        {
            IMessageConverter converter = MessageConverter;

            if (converter != null)
            {
                return(converter.FromMessage(message));
            }
            return(message);
        }
Example #26
0
        public PayloadMethodArgumentResolver(IMessageConverter messageConverter, bool useDefaultResolution)
        {
            if (messageConverter == null)
            {
                throw new ArgumentNullException(nameof(messageConverter));
            }

            _converter            = messageConverter;
            _useDefaultResolution = useDefaultResolution;
        }
Example #27
0
        public ProxyBuilder AddMessageConverter(IMessageConverter messageConverter)
        {
            if (messageConverter == null)
            {
                throw new ArgumentNullException("messageConverter");
            }

            _messageConverters.Add(messageConverter);
            return(this);
        }
Example #28
0
        public async ValueTask <IActionResult> Index(
            [FromServices] IRepository <WebEntity> repository,
            [FromServices] IRepository <WebEntity, int> repositoryWithKey,
            [FromServices] IAsyncRepository <WebEntity> asyncRepository,
            [FromServices] IAsyncRepository <WebEntity, int> asyncRepositoryWithKey,
            [FromServices] IMessageBus messageBus,
            [FromServices] IMessageConverter messageConverter)
        {
            var repositoryStatus       = "OK";
            var messageBusStatus       = "OK";
            var messageConverterStatus = "OK";

            try
            {
                var hashSet = new HashSet <DbContext>
                {
                    repository.GetDbContext(),
                    repositoryWithKey.GetDbContext(),
                    asyncRepository.GetDbContext(),
                    asyncRepositoryWithKey.GetDbContext()
                };
                hashSet.Single();
            }
            catch (Exception)
            {
                repositoryStatus = "Error";
            }
            try
            {
                var message    = new WebTestMessage();
                var descriptor = new RichMessageDescriptor("", nameof(WebTestMessage).ToLowerInvariant());
                await messageBus.OnMessageReceivedAsync(message, descriptor);
            }
            catch (Exception)
            {
                messageBusStatus = "Error";
            }
            var testMessage = new WebTestMessage
            {
                TestMessage = "debug"
            };
            var serializedMessageString = messageConverter.SerializeString(testMessage);

            if (serializedMessageString == "{}")
            {
                messageConverterStatus = "Error";
            }

            return(Json(new
            {
                RepositoryStatus = repositoryStatus,
                MessageBusStatus = messageBusStatus,
                MessageConverterStatus = messageConverterStatus,
            }));
        }
        public MessageMethodArgumentResolverTest()
        {
            method = typeof(MessageMethodArgumentResolverTest)
                     .GetMethod(
                "Handle",
                BindingFlags.NonPublic | BindingFlags.Instance);

            mock      = new Mock <IMessageConverter>();
            converter = mock.Object;
            resolver  = new MessageMethodArgumentResolver(converter);
        }
 public EventsLinkHandler(
     IIdentity identity,
     IReceivingAmqpLink link,
     Uri requestUri,
     IDictionary <string, string> boundVariables,
     IConnectionHandler connectionHandler,
     IMessageConverter <AmqpMessage> messageConverter,
     IProductInfoStore productInfoStore)
     : base(identity, link, requestUri, boundVariables, connectionHandler, messageConverter, productInfoStore)
 {
 }
Example #31
0
 public ModuleMessageLinkHandler(
     IIdentity identity,
     ISendingAmqpLink link,
     Uri requestUri,
     IDictionary <string, string> boundVariables,
     IConnectionHandler connectionHandler,
     IMessageConverter <AmqpMessage> messageConverter,
     IMetadataStore metadataStore)
     : base(identity, link, requestUri, boundVariables, connectionHandler, messageConverter, metadataStore)
 {
 }
        public DefaultAgentBroker(IMessagePublisher messagePublisher, IMessageConverter messageConverter, IContextData<MessageContext> context)
        {
            _messagePublisher = messagePublisher;
            _messageConverter = messageConverter;
            _context = context;

            _onSenderThreadSubject = new Subject<AgentBrokerPayload>();
            _offSenderThreadSubject = new Subject<AgentBrokerPayload>();
            _offSenderThreadInternalSubject = new Subject<AgentBrokerPayload>();
            _publisherInternalSubject = new Subject<AgentBrokerPayload>();

            OnSenderThread = new AgentBrokerObservations(_onSenderThreadSubject);
            OffSenderThread = new AgentBrokerObservations(_offSenderThreadSubject);

            // ensure off-request data is observed onto a different thread
            _offSenderThreadInternalSubject.Subscribe(payload => Observable.Start(() => _offSenderThreadSubject.OnNext(payload), TaskPoolScheduler.Default));
            _publisherInternalSubject.Subscribe(x => Observable.Start(() => PublishMessage(x), TaskPoolScheduler.Default));
        }
 public void testStatefulRetryWithNoMessageIds()
 {
     var messageCount = 2;
     var txSize = 1;
     var failFrequency = 1;
     var concurrentConsumers = 1;
     var messageConverter = new SimpleMessageConverter();
     // There will be no key for these messages so they cannot be recovered...
     messageConverter.CreateMessageIds = false;
     this.messageConverter = messageConverter;
     // Beware of context cache busting if retry policy fails...
     /* TODO: Once Spring Batch is implemented.
      * this.retryTemplate = new RetryTemplate();
     this.retryTemplate.setRetryContextCache(new MapRetryContextCache(1));
      */
     // The container should have shutdown, so there are now no active consumers
     //exception.expectMessage("expected:<1> but was:<0>");
     DoTestStatefulRetry(messageCount, txSize, failFrequency, concurrentConsumers);
 }
 /// <summary>
 /// Initialize the default implementations for the adapter's strategies.
 /// </summary>
 protected virtual void InitDefaultStrategies()
 {
     MessageConverter = new SimpleMessageConverter();
     processingExpression = Expression.Parse(defaultHandlerMethod + "(#convertedObject)");
 }
 /// <summary>
 /// Creates the template.
 /// </summary>
 /// <param name="concurrentConsumers">The concurrent consumers.</param>
 /// <returns>The template.</returns>
 /// <remarks></remarks>
 private RabbitTemplate CreateTemplate(int concurrentConsumers)
 {
     var template = new RabbitTemplate();
     var connectionFactory = new CachingConnectionFactory();
     connectionFactory.ChannelCacheSize = concurrentConsumers;
     connectionFactory.Port = BrokerTestUtils.GetPort();
     template.ConnectionFactory = connectionFactory;
     if (this.messageConverter == null)
     {
         var internalmessageConverter = new SimpleMessageConverter();
         internalmessageConverter.CreateMessageIds = true;
         this.messageConverter = internalmessageConverter;
     }
     template.MessageConverter = this.messageConverter;
     return template;
 }
 /// <summary>Initializes a new instance of the <see cref="MessageListenerAdapter"/> class.</summary>
 /// <param name="handlerObject">The handler object.</param>
 /// <param name="messageConverter">The message converter.</param>
 public MessageListenerAdapter(object handlerObject, IMessageConverter messageConverter)
 {
     this.InitDefaultStrategies();
     this.handlerObject = handlerObject;
     this.messageConverter = messageConverter;
 }
 public InProcessChannel(IServerBroker messageBus, IMessageConverter messageConverter)
 {
     _messageBus = messageBus;
     _messageConverter = messageConverter;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderMappingMessageConverter"/> class.
 /// that will delegate to the provided <see cref="IMessageConverter"/> instance and will use the default
 /// implementation of the <see cref="INmsHeaderMapper"/> strategy.
 /// </summary>
 /// <param name="converter">The converter.</param>
 public HeaderMappingMessageConverter(IMessageConverter converter)
     : this(converter, null)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public HeaderMappingMessageConverter(IMessageConverter converter, INmsHeaderMapper headerMapper)
 {
     this.converter = (converter != null ? converter : new SimpleMessageConverter());
     this.headerMapper = (headerMapper != null ? headerMapper : new DefaultNmsHeaderMapper());
 }
Example #40
0
 public RabbitMQPublisher(IRabbitMQConnectionAccessor connectionAccessor, IMessageConverter converter)
 {
     _converter = converter;
     _model = connectionAccessor.Connection.CreateModel();
 }
 public HttpChannelSender(IMessageConverter messageConverter)
 {
     _httpHandler = new HttpClientHandler();
     _httpClient = new HttpClient(_httpHandler);
     _messageConverter = messageConverter;
 }
 public void AfterPropertiesSet()
 {
     HeaderMappingMessageConverter headerMappingMessageConverter =
         messageConverter as HeaderMappingMessageConverter;
     if (headerMappingMessageConverter == null)
     {
         HeaderMappingMessageConverter hmmc = new HeaderMappingMessageConverter(messageConverter, headerMapper);
         hmmc.ExtractNmsMessageBody = extractRequestPayload;
         hmmc.ExtractIntegrationMessagePayload = extractReplyPayload;
         messageConverter = hmmc;
     }
 }
 public void AfterPropertiesSet()
 {
     lock (initializationMonitor)
     {
         if (initialized)
         {
             return;
         }
         AssertUtils.ArgumentNotNull(connectionFactory, "connectionFactory must not be null");
         AssertUtils.IsTrue(requestDestination != null || requestDestinationName != null,
                            "Either a 'requestDestination' or 'requestDestinationName' is required.");
         if (messageConverter == null)
         {
             HeaderMappingMessageConverter hmmc = new HeaderMappingMessageConverter(null, headerMapper);
             hmmc.ExtractIntegrationMessagePayload = extractRequestPayload;
             hmmc.ExtractNmsMessageBody = extractReplyPayload;
             messageConverter = hmmc;
         }
         initialized = true;
     }
 }
 public WebSocketChannelSender(IMessageConverter messageConverter, IStreamHubProxyFactory streamHubProxyFactory)
 {
     _messageConverter = messageConverter;
     _streamHubProxyFactory = streamHubProxyFactory;
     _streamHubProxyFactory.Register("WebSocketChannelReceiver", x => _streamHubProxy = x);
 }