Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu
Created September 26, 2019 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuannguyenssu/60877142c0bcbd80a66074a9db8c7f6a to your computer and use it in GitHub Desktop.
Save tuannguyenssu/60877142c0bcbd80a66074a9db8c7f6a to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using MassTransit;
namespace MassTransitTest.Controllers
{
[ApiController]
[Route("[controller]")]
public class MassTransitController : ControllerBase
{
private readonly IBus _bus;
private readonly ILogger<MassTransitController> _logger;
public MassTransitController(IBus bus, ILogger<MassTransitController> logger)
{
_bus = bus;
_logger = logger;
}
[HttpGet]
public async Task<string> Get()
{
string currentTime = DateTime.Now.ToString();
_logger.LogInformation($"Sent order data: {currentTime}");
await _bus.Publish<Order>(
new
{
Data = currentTime
});
return currentTime;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment