Esempio n. 1
0
        public static async Task SubscriberGetMessage()
        {
            try
            {
                Program.EnsureParam(Program.EnsureConfig.ServiceFabricAdminUri);
                Program.EnsureParam(Program.EnsureConfig.TenantName);
                Program.EnsureParam(Program.EnsureConfig.TopicName);
                Program.EnsureParam(Program.EnsureConfig.SubscriberName);
                Program.EnsureParam(Program.EnsureConfig.AccessKey);

                PubSubClientApi client = new PubSubClientApi(Program.ServiceFabricUri);
                dynamic         result = await client.Request.GetWithHttpMessagesAsync(Program.TenantName, Program.TopicName, Program.SubscriberName, AuthenticationHeader());

                Console.WriteLine("Message: " + result.Body);

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                throw new CommandFailedException("Web call failed", ex);
            }
            finally
            {
                Program.TenantName     = String.Empty;
                Program.TopicName      = String.Empty;
                Program.AccessKey      = String.Empty;
                Program.SubscriberName = String.Empty;
            }
        }
Esempio n. 2
0
        public static async Task TopicPutMessage()
        {
            //this goes to the router
            try
            {
                Program.EnsureParam(Program.EnsureConfig.ServiceFabricAdminUri);
                Program.EnsureParam(Program.EnsureConfig.TenantName);
                Program.EnsureParam(Program.EnsureConfig.TopicName);
                Program.EnsureParam(Program.EnsureConfig.AccessKey);

                Console.WriteLine("Type your message");
                var message = Console.ReadLine();

                PubSubClientApi client = new PubSubClientApi(Program.ServiceFabricUri);
                var             result = await client.Request.PostWithHttpMessagesAsync(Program.TenantName, Program.TopicName, message, AuthenticationHeader());

                Console.WriteLine("Message sent.");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                throw new CommandFailedException("Web call failed", ex);
            }
            finally
            {
                Program.TenantName = String.Empty;
                Program.TopicName  = String.Empty;
                Program.AccessKey  = String.Empty;
            }
        }