-
-
Save tuannguyenssu/60877142c0bcbd80a66074a9db8c7f6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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