class PublisherConfirms
{
public void Test(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
using (var channel = connection.CreateModel())
{
channel.QueueDeclare(
queue: "task_queue",
durable: true,
exclusive: false,
autoDelete: false,
arguments: null);
var message = GetMessage(args);
var body = Encoding.UTF8.GetBytes(message);
channel.BasicAcks += Channel_BasicAcks;
//1
channel.ConfirmSelect(); //You’ll get an IllegalStateException if you try to use either variation of WaitForConfirms without first setting the Confirms property with ConfirmSelect.
var properties = channel.CreateBasicProperties();
properties.SetPersistent(true);
//messages are routed to the queue with the name specified by routingKey, if it exists.
channel.BasicPublish(
exchange: "",
routingKey: "task_queue",
basicProperties: properties,
body: body);
//2
channel.WaitForConfirmsOrDie();
Console.WriteLine(" [x] Sent {0}", message);
}
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
private void Channel_BasicAcks(object sender, RabbitMQ.Client.Events.BasicAckEventArgs e)
{
throw new NotImplementedException();
}
private static string GetMessage(string[] args)
{
return ((args.Length > 0) ? string.Join(" ", args) : "Hello World!");
}
}--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
channel.BasicAcks += Channel_BasicAcks;To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Michael,
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
`rabbitmqctl stop` but that's not the scenario you want because it will close all client connections cleanly.You probably want to just kill the running OS process or block traffic using iptables or similar.
On Thu, Mar 15, 2018 at 5:08 PM, Ping <pingpongo...@gmail.com> wrote:
Hi Michael,Thanks. I am new to RabbitMQ.When exactly should RabbitMQ server be killed? Do you mean after channel.BasicPublish() is called? In that case, how is it possible for me to issue rabbitmqctl command to kill it? Because it is like ms time.What exact argument should be used with rabbitmqctl ?rabbitmqctl shutdownorrabbitmqctl stop pid
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.