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
70984214
authored
Apr 04, 2022
by
AlexNasyr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
receiving msgs from activeMQ query realized
parent
d09d1666
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
5 deletions
SocialMinistryDataExchange/Controllers/apiController.cs
SocialMinistryDataExchange/Model/ActiveMqExtensions.cs
SocialMinistryDataExchange/SocialMinistryDataExchange.csproj
SocialMinistryDataExchange/Startup.cs
SocialMinistryDataExchange/Controllers/apiController.cs
View file @
70984214
...
...
@@ -11,9 +11,13 @@ namespace SocialMinistryDataExchange.Controllers {
public
class
apiController
:
ControllerBase
{
private
readonly
ISMRepository
_repository
;
private
readonly
MessageProducer
_messageProducer
;
public
apiController
(
ISMRepository
repository
,
MessageProducer
messageProducer
)
{
_repository
=
repository
;
//private readonly StringMessageCunsomer _cunsomer;
//public apiController(ISMRepository repository, MessageProducer messageProducer, StringMessageCunsomer cunsomer) {
public
apiController
(
ISMRepository
repository
,
MessageProducer
messageProducer
)
{
_repository
=
repository
;
_messageProducer
=
messageProducer
;
//_cunsomer = cunsomer;
}
//тестовый запрос для симуляции получения XML запроса (берется из файла)
...
...
@@ -35,7 +39,6 @@ namespace SocialMinistryDataExchange.Controllers {
return
StatusCode
((
int
)
HttpStatusCode
.
Created
,
null
);
}
// тестовый запрос зачисленности личности
[
HttpGet
]
[
Route
(
"[controller]/getFixPerson"
)]
public
async
Task
<
SMPersonDataRequest
>
GetFixPerson
()
{
...
...
SocialMinistryDataExchange/Model/ActiveMqExtensions.cs
View file @
70984214
...
...
@@ -2,13 +2,34 @@
using
ActiveMQ.Artemis.Client.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection.Extensions
;
using
SocialMinistryDataExchange.Model.EscpSD
;
using
System
;
using
System.IO
;
using
System.Text.Json
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Xml.Serialization
;
namespace
SocialMinistryDataExchange.Model
{
public
static
class
ActiveMqExtensions
{
public
static
IActiveMqBuilder
AddTypedConsumer
<
TMessage
,
TConsumer
>(
this
IActiveMqBuilder
builder
,
string
address
,
RoutingType
routingType
)
where
TConsumer
:
class
,
ITypedConsumer
<
TMessage
>
{
builder
.
Services
.
TryAddScoped
<
TConsumer
>();
builder
.
AddConsumer
(
address
,
routingType
,
HandleMessage
<
TMessage
,
TConsumer
>);
return
builder
;
}
private
static
async
Task
HandleMessage
<
TMessage
,
TConsumer
>(
Message
message
,
IConsumer
consumer
,
IServiceProvider
serviceProvider
,
CancellationToken
token
)
where
TConsumer
:
class
,
ITypedConsumer
<
TMessage
>
{
var
msg
=
(
TMessage
)
Convert
.
ChangeType
(
message
.
GetBody
<
string
>(),
typeof
(
TMessage
));
using
var
scope
=
serviceProvider
.
CreateScope
();
var
typedConsumer
=
scope
.
ServiceProvider
.
GetService
<
TConsumer
>();
await
typedConsumer
.
ConsumeAsync
(
msg
,
token
);
await
consumer
.
AcceptAsync
(
message
);
}
/*
//public static IActiveMqBuilder AddTypedConsumer<TMessage, TConsumer>(this IActiveMqBuilder builder, RoutingType routingType) where TConsumer : class, ITypedConsumer<TMessage> {
public static IActiveMqBuilder AddTypedConsumer<TMessage, TConsumer>(this IActiveMqBuilder builder, string address, RoutingType routingType) where TConsumer : class, ITypedConsumer<TMessage> {
builder.Services.TryAddScoped<TConsumer>();
...
...
@@ -23,5 +44,6 @@ namespace SocialMinistryDataExchange.Model {
await typedConsumer.ConsumeAsync(msg, token);
await consumer.AcceptAsync(message);
}
*/
}
}
\ No newline at end of file
SocialMinistryDataExchange/SocialMinistryDataExchange.csproj
View file @
70984214
...
...
@@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="ArtemisNetClient" Version="2.7.0" />
<PackageReference Include="ArtemisNetClient.Extensions.DependencyInjection" Version="2.7.0" />
<PackageReference Include="ArtemisNetClient.Extensions.Hosting" Version="2.7.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
...
...
SocialMinistryDataExchange/Startup.cs
View file @
70984214
using
ActiveMQ.Artemis.Client
;
using
ActiveMQ.Artemis.Client.Extensions.DependencyInjection
;
using
ActiveMQ.Artemis.Client.Extensions.Hosting
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.EntityFrameworkCore
;
...
...
@@ -12,6 +13,7 @@ using Serilog;
using
Serilog.Events
;
using
SocialMinistryDataExchange.Model
;
using
SocialMinistryDataExchange.Model.Contingent.Center
;
using
SocialMinistryDataExchange.Model.EscpSD
;
using
System
;
using
System.IO
;
...
...
@@ -46,9 +48,10 @@ namespace SocialMinistryDataExchange {
string
SmQueue
=
"MV.SMEV_INF_DAN_OBE_ZHIL.REQ"
;
try
{
services
.
AddActiveMq
(
"ddoApp-cluster"
,
new
[]
{
Endpoint
.
Create
(
host
:
"172.17.100.121"
,
port
:
61616
,
"
"
,
"
"
)
})
services
.
AddActiveMq
(
"ddoApp-cluster"
,
new
[]
{
Endpoint
.
Create
(
host
:
"172.17.100.121"
,
port
:
61616
,
"
contingent"
,
"RjQ66VWS
"
)
})
.
AddProducer
<
MessageProducer
>(
SmQueue
,
RoutingType
.
Anycast
)
.
AddTypedConsumer
<
string
,
StringMessageCunsomer
>(
SmQueue
,
RoutingType
.
Anycast
);
.
AddTypedConsumer
<
String
,
StringMessageCunsomer
>(
SmQueue
,
RoutingType
.
Anycast
);
services
.
AddActiveMqHostedService
();
}
catch
(
Exception
ex
)
{
}
...
...
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