Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
1e69d71a
Commit
1e69d71a
authored
Nov 26, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify prompted info when received message can not be found subscriber. #63
parent
2504c7af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
14 deletions
+34
-14
ISubscriberExecutor.Default.cs
src/DotNetCore.CAP/Internal/ISubscriberExecutor.Default.cs
+10
-13
MethodMatcherCache.cs
src/DotNetCore.CAP/Internal/MethodMatcherCache.cs
+23
-0
CapReceivedMessage.cs
src/DotNetCore.CAP/Models/CapReceivedMessage.cs
+1
-1
No files found.
src/DotNetCore.CAP/Internal/ISubscriberExecutor.Default.cs
View file @
1e69d71a
using
System
;
using
System
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Abstractions
;
using
DotNetCore.CAP.Abstractions
;
using
DotNetCore.CAP.Models
;
using
DotNetCore.CAP.Models
;
...
@@ -28,22 +29,18 @@ namespace DotNetCore.CAP.Internal
...
@@ -28,22 +29,18 @@ namespace DotNetCore.CAP.Internal
public
async
Task
<
OperateResult
>
ExecuteAsync
(
CapReceivedMessage
receivedMessage
)
public
async
Task
<
OperateResult
>
ExecuteAsync
(
CapReceivedMessage
receivedMessage
)
{
{
try
if
(!
_selector
.
TryGetTopicExector
(
receivedMessage
.
Name
,
receivedMessage
.
Group
,
{
out
var
executor
))
var
executeDescriptorGroup
=
_selector
.
GetTopicExector
(
receivedMessage
.
Name
);
if
(!
executeDescriptorGroup
.
ContainsKey
(
receivedMessage
.
Group
))
{
{
var
error
=
$"Topic:
{
receivedMessage
.
Name
}
, can not be found subscriber method."
;
var
error
=
"this message can not be found subscriber. Message:"
+
receivedMessage
;
error
+=
"\r\n see: https://github.com/dotnetcore/CAP/issues/63"
;
throw
new
SubscriberNotFoundException
(
error
);
throw
new
SubscriberNotFoundException
(
error
);
}
}
// If there are multiple consumers in the same group, we will take the first
var
consumerContext
=
new
ConsumerContext
(
executor
,
receivedMessage
.
ToMessageContext
());
var
executeDescriptor
=
executeDescriptorGroup
[
receivedMessage
.
Group
][
0
];
try
var
consumerContext
=
new
ConsumerContext
(
executeDescriptor
,
receivedMessage
.
ToMessageContext
());
{
var
ret
=
await
Invoker
.
InvokeAsync
(
consumerContext
);
var
ret
=
await
Invoker
.
InvokeAsync
(
consumerContext
);
if
(!
string
.
IsNullOrEmpty
(
ret
.
CallbackName
))
if
(!
string
.
IsNullOrEmpty
(
ret
.
CallbackName
))
await
_callbackMessageSender
.
SendAsync
(
ret
.
MessageId
,
ret
.
CallbackName
,
ret
.
Result
);
await
_callbackMessageSender
.
SendAsync
(
ret
.
MessageId
,
ret
.
CallbackName
,
ret
.
Result
);
...
...
src/DotNetCore.CAP/Internal/MethodMatcherCache.cs
View file @
1e69d71a
...
@@ -55,6 +55,29 @@ namespace DotNetCore.CAP.Internal
...
@@ -55,6 +55,29 @@ namespace DotNetCore.CAP.Internal
return
dic
;
return
dic
;
}
}
/// <summary>
/// Attempts to get the topic exector associated with the specified topic name and group name from the <see cref="Entries"/>.
/// </summary>
/// <param name="topicName">The topic name of the value to get.</param>
/// <param name="groupName">The group name of the value to get.</param>
/// <param name="matchTopic">topic exector of the value.</param>
/// <returns>true if the key was found, otherwise false. </returns>
public
bool
TryGetTopicExector
(
string
topicName
,
string
groupName
,
out
ConsumerExecutorDescriptor
matchTopic
)
{
if
(
Entries
==
null
)
throw
new
ArgumentNullException
(
nameof
(
Entries
));
matchTopic
=
null
;
if
(
Entries
.
TryGetValue
(
groupName
,
out
var
groupMatchTopics
))
{
matchTopic
=
groupMatchTopics
.
FirstOrDefault
(
x
=>
x
.
Attribute
.
Name
==
topicName
);
return
matchTopic
!=
null
;
}
return
false
;
}
/// <summary>
/// <summary>
/// Get all subscribe topics name.
/// Get all subscribe topics name.
/// </summary>
/// </summary>
...
...
src/DotNetCore.CAP/Models/CapReceivedMessage.cs
View file @
1e69d71a
...
@@ -47,7 +47,7 @@ namespace DotNetCore.CAP.Models
...
@@ -47,7 +47,7 @@ namespace DotNetCore.CAP.Models
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
"name:"
+
Name
+
", content:"
+
Content
;
return
"name:"
+
Name
+
",
group:"
+
Group
+
",
content:"
+
Content
;
}
}
}
}
}
}
\ No newline at end of file
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