Commit 1d34cada by AlexNasyr

00

parent 28240cdf
...@@ -15,6 +15,8 @@ namespace DDO_Application.Controllers { ...@@ -15,6 +15,8 @@ namespace DDO_Application.Controllers {
private readonly MessageProducer _messageProducer; private readonly MessageProducer _messageProducer;
private IApiService _apiService; private IApiService _apiService;
private string GUID = "e6c77d95-54a7-4645-818b-16fd71322b6e";
public IServiceProvider Services { get; } public IServiceProvider Services { get; }
public apiController(IServiceProvider services, MessageProducer messageProducer) { public apiController(IServiceProvider services, MessageProducer messageProducer) {
...@@ -40,15 +42,15 @@ namespace DDO_Application.Controllers { ...@@ -40,15 +42,15 @@ namespace DDO_Application.Controllers {
[HttpPost] [HttpPost]
[Route("[controller]/sendmsg/{msg}")] [Route("[controller]/sendmsg/{msg}")]
public async Task<IActionResult> SendMessage(string msg) { public async Task<IActionResult> SendMessage(string msg) {
var @event = new TestMessage { Id = 1, Message = msg}; var @event = new TestMessage { businessId = "1", Message = msg};
await _messageProducer.PublishAsync(@event); await _messageProducer.PublishAsync(@event);
return StatusCode((int)HttpStatusCode.Created, null); return StatusCode((int)HttpStatusCode.Created, null);
} }
[HttpPost] [HttpPost]
[Route("[controller]/sendmsg/smev_init")] [Route("[controller]/sendmsg/smev_init")]
public async Task<IActionResult> SendInitMessage(string msg) { public async Task<IActionResult> SendInitMessage() {
var @event = new TestMessage { Id = 1, Message = msg }; var @event = new TestMessage { businessId = GUID, Message = @"<?xml version=""1.0"" encoding=""UTF-8""?><xsd:schema xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:tns=""http://epgu.gosuslugi.ru/concentrator/kindergarten/3.2.1"" targetNamespace=""http://epgu.gosuslugi.ru/concentrator/kindergarten/3.2.1"" elementFormDefault=""qualified"" attributeFormDefault=""unqualified""></xsd:schema>" };
await _messageProducer.PublishAsync(@event); await _messageProducer.PublishAsync(@event);
return StatusCode((int)HttpStatusCode.Created, null); return StatusCode((int)HttpStatusCode.Created, null);
} }
......
...@@ -12,7 +12,10 @@ namespace DDO_Application.Model { ...@@ -12,7 +12,10 @@ namespace DDO_Application.Model {
} }
public async Task PublishAsync<T>(T message) { public async Task PublishAsync<T>(T message) {
var serialized = JsonSerializer.Serialize(message); var serialized = JsonSerializer.Serialize(message);
var msg = new Message(serialized); var msg = new Message(serialized);
msg.MessageId = "e6c77d95-54a7-4645-818b-16fd71322b6e";
await _producer.SendAsync(msg); await _producer.SendAsync(msg);
} }
} }
......
namespace DDO_Application.Model { namespace DDO_Application.Model {
public class TestMessage { public class TestMessage {
public int Id { get; set; } public string businessId { get; set; }
public string Message { get; set; } public string Message { get; set; }
} }
} }
...@@ -24,20 +24,21 @@ namespace DDO_Application { ...@@ -24,20 +24,21 @@ namespace DDO_Application {
var ActiveMQ = Configuration.GetSection("ActiveMQ").Get<configActiveMQ>().Endpoint; var ActiveMQ = Configuration.GetSection("ActiveMQ").Get<configActiveMQ>().Endpoint;
var msgQueues = Configuration.GetSection("TestQueues").Get<configTestQueues>(); var msgQueues = Configuration.GetSection("TestQueues").Get<configTestQueues>();
string queue1 = "SMEV3_V12.GET_REQUEST_RESPONSE";
string queue2 = "CONTINGENT.APPLICATION_INC"; string queue2 = "CONTINGENT.APPLICATION_INC";
string queue3 = "CONTINGENT.MV.REQ"; string queue3 = "CONTINGENT.MV.REQ";
string queue4 = "CONTINGENT.MV.RESP"; string queue4 = "CONTINGENT.MV.RESP";
string GUID = "e6c77d95-54a7-4645-818b-16fd71322b6e";
services.AddControllers(); services.AddControllers();
services.AddSwaggerGen(c => {c.SwaggerDoc("v1", new OpenApiInfo { Title = "DDO_Application", Version = "v1" }); }); services.AddSwaggerGen(c => {c.SwaggerDoc("v1", new OpenApiInfo { Title = "DDO_Application", Version = "v1" }); });
services.AddHostedService<ApiHostedService>(); services.AddHostedService<ApiHostedService>();
services.AddSingleton<IApiService, ApiProcessingService>(); services.AddSingleton<IApiService, ApiProcessingService>();
// turn enable ActiveMQ support in project // turn enable ActiveMQ support in project
//services.AddActiveMq("ddoApp-cluster", new[] { Endpoint.Create(host: "172.17.100.121", port: 61616, "contingent", "RjQ66VWS") }) //services.AddActiveMq("ddoApp-cluster", new[] { Endpoint.Create(host: "172.17.100.121", port: 61616, "contingent", "RjQ66VWS") })
//services.AddActiveMq("ddoApp-cluster", new[] { Endpoint.Create(host: "192.168.2.19", port: 5672, "guest", "guest") }) services.AddActiveMq("ddoApp-cluster", new[] { Endpoint.Create(host: "192.168.2.19", port: 5672, "guest", "guest") })
services.AddActiveMq("ddoApp-cluster", new[] { ActiveMQ }) //services.AddActiveMq("ddoApp-cluster", new[] { ActiveMQ })
//.AddProducer<MessageProducer>(queue2) //.AddProducer<MessageProducer>(queue2, RoutingType.Anycast)
//.AddTypedConsumer<TestMessage, TestMessageCunsomer>(queue2, RoutingType.Anycast); //.AddTypedConsumer<TestMessage, TestMessageCunsomer>(queue2, RoutingType.Anycast);
.AddProducer<MessageProducer>(msgQueues.Out, RoutingType.Multicast) .AddProducer<MessageProducer>(msgQueues.Out, RoutingType.Multicast)
.AddTypedConsumer<TestMessage, TestMessageCunsomer>(msgQueues.In, RoutingType.Multicast); .AddTypedConsumer<TestMessage, TestMessageCunsomer>(msgQueues.In, RoutingType.Multicast);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment