Skip to content

Instantly share code, notes, and snippets.

@hkucuk
Last active January 8, 2022 10:27
Show Gist options
  • Select an option

  • Save hkucuk/e547614e766a2d852101f239e10c1a54 to your computer and use it in GitHub Desktop.

Select an option

Save hkucuk/e547614e766a2d852101f239e10c1a54 to your computer and use it in GitHub Desktop.

Revisions

  1. hkucuk revised this gist Jan 8, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rabbitmq_publisher.cs
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@

    var factory = new ConnectionFactory();
    //AMQP URL
    factory.Uri = new Uri("amqps://fxunuiqu:your_url");
    factory.Uri = new Uri("amqps://fxunuiqu:url_adres");
    var queueName = "test-queue";

    using (var connection = factory.CreateConnection())
  2. hkucuk renamed this gist Jan 8, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. hkucuk revised this gist Jan 8, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rabbitmq_publisher
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ using RabbitMQ.Client;

    var factory = new ConnectionFactory();
    //AMQP URL
    factory.Uri = new Uri("amqps://fxunuiqu:AKyj5ShMAw-AmH3InEBx6G_lQov-Cofs@puffin.rmq2.cloudamqp.com/fxunuiqu");
    factory.Uri = new Uri("amqps://fxunuiqu:your_url");
    var queueName = "test-queue";

    using (var connection = factory.CreateConnection())
  4. hkucuk revised this gist Jan 8, 2022. No changes.
  5. hkucuk created this gist Jan 8, 2022.
    37 changes: 37 additions & 0 deletions rabbitmq_publisher
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    using System.Text;
    using RabbitMQ.Client;

    var factory = new ConnectionFactory();
    //AMQP URL
    factory.Uri = new Uri("amqps://fxunuiqu:AKyj5ShMAw-AmH3InEBx6G_lQov-Cofs@puffin.rmq2.cloudamqp.com/fxunuiqu");
    var queueName = "test-queue";

    using (var connection = factory.CreateConnection())
    {
    var channel = connection.CreateModel();
    channel.QueueDeclare
    (
    queue: queueName,
    durable: true, //true degeri kuyruk bellekte oluşturulmasın ve fiziksel olarak kaydedilsin anlamina gelir.
    exclusive: false,//false degeri kuyruga sadece olsuturuldugu makineden degil heryerden baglanılabilsin anlamina gelir.
    autoDelete: false //false degeri istemcilerin işi bittiğinde kuyruk otomatik olarak silinmesin anlamina gelir.
    );

    for (int i = 0; i < 50; i++)
    {
    var data = Encoding.UTF8.GetBytes($"{i}. mesaj : {Guid.NewGuid()}");
    channel.BasicPublish
    (
    exchange: "",
    routingKey: queueName,
    mandatory: true,
    basicProperties: null,
    body: data
    );

    Console.WriteLine($"{i}. mesaj gönderildi.");
    }
    }

    Console.WriteLine("Mesaj Gönderildi");
    Console.Read();