Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="messageHandler"></param>
        /// <param name="options"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <Subscription> SubscribeAsync(IMessageReceivedHandler <string> messageHandler, MessageOptions options, CancellationToken token)
        {
            /* this approach requires share cliend it and client secret from azure resources from the namespace.but following a design principle that resources must be created
             * in advance when deploying environment,the application must log only if suscription is not there
             * var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(CLIENT_ID, CLIENT_SECRET, TENANT_ID, AzureEnvironment.AzureGlobalCloud);
             *  var serviceBusManager = ServiceBusManager.Authenticate(credentials, SUBSCRIPTION_ID);
             * serviceBusNamespace = serviceBusManager.Namespaces.GetByResourceGroup(RESOURCE_GROUP, RESOURCE_NAME);
             */

            //   await PickUpAndFixDeadletters(this.connectionSettings.ConnectionString, "dead-letter", token);
            this.messageHandler = messageHandler;
            RegisterOnMessageHandlerAndReceiveMessages(options);
            this.subscriptionId = Guid.NewGuid();
            return(new Subscription(this.subscriptionId));
        }
Ejemplo n.º 2
0
 public static IMqttClient UseApplicationMessageReceivedHandler(this IMqttClient client, IMessageReceivedHandler handler)
 {
     client.MessageReceivedHandler = handler;
     return(client);
 }