using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RabbitMQ.Client;
namespace RabbitMQSend
{
public partial class Form1 : Form
{
string message;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
using (var channel = connection.CreateModel())
{
channel.QueueDeclare(queue: "hello2",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
message = textBox1.Text;
var body = Encoding.UTF8.GetBytes(message);
channel.BasicPublish(exchange: "",
routingKey: "hello2",
basicProperties: null,
body: body);
//Console.WriteLine(" [x] Sent {0}", message);
}
label1.Text = message + "전송 완료";
//Console.WriteLine(" Press [enter] to exit.");
//Console.ReadLine();
}
}
}