You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
861 B

  1. using System;
  2. using System.Threading.Tasks;
  3. using DotNetCore.CAP;
  4. using Microsoft.AspNetCore.Mvc;
  5. namespace Sample.Pulsar.InMemory.Controllers
  6. {
  7. [Route("api/[controller]")]
  8. public class ValuesController : Controller, ICapSubscribe
  9. {
  10. private readonly ICapPublisher _capBus;
  11. public ValuesController(ICapPublisher producer)
  12. {
  13. _capBus = producer;
  14. }
  15. [Route("~/without/transaction")]
  16. public async Task<IActionResult> WithoutTransaction()
  17. {
  18. await _capBus.PublishAsync("persistent://public/default/captesttopic", DateTime.Now);
  19. return Ok();
  20. }
  21. [CapSubscribe("persistent://public/default/captesttopic")]
  22. public void Test2T2(string value)
  23. {
  24. Console.WriteLine("Subscriber output message: " + value);
  25. }
  26. }
  27. }