Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Marat Pavlov
/
AlexAdapter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
686bbe47
authored
Apr 01, 2022
by
AlexNasyr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddo - msg broker string message added
parent
a6167d6f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
10 deletions
DDO_Application/Controllers/apiController.cs
DDO_Application/Model/TestMessageCunsomer.cs → DDO_Application/Model/MessageCunsomers.cs
DDO_Application/Model/MessageProducer.cs
DDO_Application/Startup.cs
SocialMinistryDataExchange/Model/SMRepository.cs
DDO_Application/Controllers/apiController.cs
View file @
686bbe47
...
...
@@ -54,7 +54,7 @@ namespace DDO_Application.Controllers {
[
HttpPost
]
[
Route
(
"[controller]/sendmsg/{msg}"
)]
public
async
Task
<
IActionResult
>
SendMessage
(
string
msg
)
{
var
@event
=
new
TestMessage
{
businessId
=
"
1
"
,
Message
=
msg
};
var
@event
=
new
TestMessage
{
businessId
=
"
e6c77d95-54a7-4645-818b-16fd71322b6e
"
,
Message
=
msg
};
await
_messageProducer
.
PublishAsync
(
@event
);
return
StatusCode
((
int
)
HttpStatusCode
.
Created
,
null
);
}
...
...
@@ -62,7 +62,14 @@ namespace DDO_Application.Controllers {
[
HttpPost
]
[
Route
(
"[controller]/sendmsg/smev_init"
)]
public
async
Task
<
IActionResult
>
SendInitMessage
()
{
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>"
};
//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>" };
//var @event = @"<?xml version=""1.0"" encoding=""utf-8""?>
// <ns:FormData oktmo=""00000000000"" xmlns: ns=""http://epgu.gosuslugi.ru/concentrator/kindergarten/3.2.1"">
// <ns:ApplicationRequest>
// <ns:TestData>Blah-Blah</ns:TestData>
// </ns:ApplicationRequest>
// </ns:FormData>";
var
@event
=
"Hello, bliya!"
;
await
_messageProducer
.
PublishAsync
(
@event
);
return
StatusCode
((
int
)
HttpStatusCode
.
Created
,
null
);
}
...
...
DDO_Application/Model/
TestMessageCunsomer
.cs
→
DDO_Application/Model/
MessageCunsomers
.cs
View file @
686bbe47
...
...
@@ -4,15 +4,21 @@ using System.Threading.Tasks;
namespace
DDO_Application.Model
{
public
class
TestMessageCunsomer
:
ITypedConsumer
<
TestMessage
>
{
public
TestMessageCunsomer
()
{
}
public
async
Task
ConsumeAsync
(
TestMessage
message
,
CancellationToken
cancellationToken
)
{
// тут логика
Console
.
WriteLine
(
message
);
}
}
public
class
StringMessageCunsomer
:
ITypedConsumer
<
String
>
{
public
StringMessageCunsomer
()
{
}
public
async
Task
ConsumeAsync
(
String
message
,
CancellationToken
cancellationToken
)
{
// тут логика
Console
.
WriteLine
(
message
);
}
}
}
DDO_Application/Model/MessageProducer.cs
View file @
686bbe47
using
ActiveMQ.Artemis.Client
;
using
Microsoft.Extensions.Configuration
;
using
System
;
using
System.Text.Json
;
using
System.Threading.Tasks
;
...
...
@@ -14,12 +15,15 @@ namespace DDO_Application.Model {
var
serialized
=
JsonSerializer
.
Serialize
(
message
);
var
msg
=
new
Message
(
serialized
)
{
Message
Id
=
"e6c77d95-54a7-4645-818b-16fd71322b6e"
//business
Id = "e6c77d95-54a7-4645-818b-16fd71322b6e"
};
await
_producer
.
SendAsync
(
msg
);
try
{
await
_producer
.
SendAsync
(
msg
);
}
catch
(
Exception
ex
)
{
}
}
}
}
\ No newline at end of file
DDO_Application/Startup.cs
View file @
686bbe47
...
...
@@ -43,7 +43,9 @@ namespace DDO_Application {
//services.AddActiveMq("ddoApp-cluster", new[] { Endpoint.Create(host: "192.168.2.22", port: 5672, "admin", "admin") })
//services.AddActiveMq("ddoApp-cluster", new[] { ActiveMQ })
.
AddProducer
<
MessageProducer
>(
queue2
,
RoutingType
.
Anycast
)
.
AddTypedConsumer
<
TestMessage
,
TestMessageCunsomer
>(
queue2
,
RoutingType
.
Anycast
);
.
AddTypedConsumer
<
TestMessage
,
TestMessageCunsomer
>(
queue2
,
RoutingType
.
Anycast
)
.
AddTypedConsumer
<
String
,
StringMessageCunsomer
>(
queue2
,
RoutingType
.
Anycast
);
//.AddProducer<MessageProducer>(msgQueues.Out, RoutingType.Multicast)
//.AddTypedConsumer<TestMessage, TestMessageCunsomer>(msgQueues.In, RoutingType.Multicast);
...
...
SocialMinistryDataExchange/Model/SMRepository.cs
View file @
686bbe47
...
...
@@ -32,6 +32,8 @@ namespace SocialMinistryDataExchange.Model {
using
(
StringWriter
writer
=
new
())
{
xmlSerializer
.
Serialize
(
writer
,
request
);
responce
=
writer
.
ToString
();
}
return
Task
.
FromResult
(
responce
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment