public static async Task PublishMessageToDefaultTopic()

in Sample-Code-Snippets/NET/ServiceBus.Emulator.Console.Sample/ServiceBus.Emulator.Console.Sample/Program.cs [92:136]


    public static async Task PublishMessageToDefaultTopic()
    {
        var topicName = "topic.1";

        await using (var client = new ServiceBusClient(_connectionString))
        {
            ServiceBusSender sender = client.CreateSender(topicName);

            //First 50 message will goto Subscription 1 and Subscription 3 as per set filters in Config.json
            for (int i = 1; i <= 50; i++)
            {
                ServiceBusMessage message = new ServiceBusMessage(Encoding.UTF8.GetBytes($"Message number : {i}"))
                {
                    ContentType = "application/json"
                };

                await sender.SendMessageAsync(message);
            }

            //Next 50 message will goto Subscription 2 and Subscription 3 as per set filters  in Config.json

            for (int i = 51; i <= 100; i++)
            {
                ServiceBusMessage message = new ServiceBusMessage(Encoding.UTF8.GetBytes($"Message number : {i}"));
                message.ApplicationProperties.Add("prop1", "value1");

                await sender.SendMessageAsync(message);
            }

            //Next 50 message will goto Subscription 3 and Subscription 4 as per set filters  in Config.json

            for (int i = 101; i <= 150; i++)
            {
                ServiceBusMessage message = new ServiceBusMessage(Encoding.UTF8.GetBytes($"Message number : {i}"))
                {
                    MessageId = "123456"
                };
                message.ApplicationProperties.Add("userProp1", "value1");

                await sender.SendMessageAsync(message);
            }
        }

        Console.WriteLine("Sent 100 messages to the topic.");
    }