Skip to content

Instantly share code, notes, and snippets.

View irfan-yusanif's full-sized avatar

Irfan irfan-yusanif

View GitHub Profile
@irfan-yusanif
irfan-yusanif / PlaceOrderHandler.cs
Last active December 2, 2021 08:04
Receive message
public class PlaceOrderHandler :
IHandleMessages<PlaceOrder>
{
static readonly ILog log = LogManager.GetLogger<PlaceOrderHandler>();
static readonly Random random = new Random();
public Task Handle(PlaceOrder message, IMessageHandlerContext context)
{
log.Info($"Received PlaceOrder, OrderId = {message.OrderId}");
public class HomeController : Controller
{
static int messagesSent;
private readonly ILogger<HomeController> _log;
private readonly IMessageSession _messageSession;
public HomeController(IMessageSession messageSession, ILogger<HomeController> logger)
{
_messageSession = messageSession;
_log = logger;
@irfan-yusanif
irfan-yusanif / Program.cs
Last active December 2, 2021 07:48
Configure NserviceBus
class Program
{
static async Task Main(string[] args)
{
await CreateHostBuilder(args).RunConsoleAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
@irfan-yusanif
irfan-yusanif / Receiver.cs
Created November 28, 2021 11:45
Receive message
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using System;
using System.Text;
class Receive
{
public static void Main()
{
var factory = new ConnectionFactory() { HostName = "localhost" };
@irfan-yusanif
irfan-yusanif / Sender.cs
Created November 28, 2021 11:40
Send message to Queue
using System;
using RabbitMQ.Client;
using System.Text;
class Send
{
public static void Main()
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using(var connection = factory.CreateConnection())