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
1f2716f9
Commit
1f2716f9
authored
Jul 02, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor.
parent
03dc95fa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
39 deletions
+45
-39
DefaultModelBinder.cs
src/DotNetCore.CAP/Internal/DefaultModelBinder.cs
+3
-3
IConsumerInvoker.Default.cs
src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs
+17
-30
IJob.CapJob.cs
src/DotNetCore.CAP/Job/IJob.CapJob.cs
+14
-6
LoggerExtensions.cs
src/DotNetCore.CAP/LoggerExtensions.cs
+11
-0
No files found.
src/DotNetCore.CAP/Internal/DefaultModelBinder.cs
View file @
1f2716f9
...
@@ -3,7 +3,7 @@ using System.Linq.Expressions;
...
@@ -3,7 +3,7 @@ using System.Linq.Expressions;
using
System.Reflection
;
using
System.Reflection
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Abstractions.ModelBinding
;
using
DotNetCore.CAP.Abstractions.ModelBinding
;
using
Newtonsoft.Json
;
using
DotNetCore.CAP.Infrastructure
;
namespace
DotNetCore.CAP.Internal
namespace
DotNetCore.CAP.Internal
{
{
...
@@ -18,7 +18,7 @@ namespace DotNetCore.CAP.Internal
...
@@ -18,7 +18,7 @@ namespace DotNetCore.CAP.Internal
bindingContext
.
Model
=
CreateModel
(
bindingContext
);
bindingContext
.
Model
=
CreateModel
(
bindingContext
);
}
}
bindingContext
.
Result
=
JsonConvert
.
DeserializeObject
(
bindingContext
.
Values
,
bindingContext
.
ModelType
);
bindingContext
.
Result
=
Helper
.
FromJson
(
bindingContext
.
Values
,
bindingContext
.
ModelType
);
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
}
...
...
src/DotNetCore.CAP/Internal/IConsumerInvoker.Default.cs
View file @
1f2716f9
...
@@ -11,9 +11,9 @@ namespace DotNetCore.CAP.Internal
...
@@ -11,9 +11,9 @@ namespace DotNetCore.CAP.Internal
{
{
protected
readonly
ILogger
_logger
;
protected
readonly
ILogger
_logger
;
protected
readonly
IServiceProvider
_serviceProvider
;
protected
readonly
IServiceProvider
_serviceProvider
;
protected
readonly
ConsumerContext
_consumerContext
;
private
readonly
IModelBinder
_modelBinder
;
private
readonly
IModelBinder
_modelBinder
;
private
readonly
ObjectMethodExecutor
_executor
;
private
readonly
ObjectMethodExecutor
_executor
;
protected
readonly
ConsumerContext
_consumerContext
;
public
DefaultConsumerInvoker
(
ILogger
logger
,
public
DefaultConsumerInvoker
(
ILogger
logger
,
IServiceProvider
serviceProvider
,
IServiceProvider
serviceProvider
,
...
@@ -29,15 +29,11 @@ namespace DotNetCore.CAP.Internal
...
@@ -29,15 +29,11 @@ namespace DotNetCore.CAP.Internal
}
}
public
Task
InvokeAsync
()
public
Task
InvokeAsync
()
{
try
{
{
using
(
_logger
.
BeginScope
(
"consumer invoker begin"
))
using
(
_logger
.
BeginScope
(
"consumer invoker begin"
))
{
{
_logger
.
LogDebug
(
"Executing consumer Topic: {0}"
,
_consumerContext
.
ConsumerDescriptor
.
Attribut
e
);
_logger
.
LogDebug
(
"Executing consumer Topic: {0}"
,
_consumerContext
.
ConsumerDescriptor
.
MethodInfo
.
Nam
e
);
try
{
var
obj
=
ActivatorUtilities
.
GetServiceOrCreateInstance
(
_serviceProvider
,
_consumerContext
.
ConsumerDescriptor
.
ImplTypeInfo
.
AsType
());
var
obj
=
ActivatorUtilities
.
GetServiceOrCreateInstance
(
_serviceProvider
,
_consumerContext
.
ConsumerDescriptor
.
ImplTypeInfo
.
AsType
());
var
value
=
_consumerContext
.
DeliverMessage
.
Content
;
var
value
=
_consumerContext
.
DeliverMessage
.
Content
;
...
@@ -58,15 +54,6 @@ namespace DotNetCore.CAP.Internal
...
@@ -58,15 +54,6 @@ namespace DotNetCore.CAP.Internal
}
}
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
}
finally
{
_logger
.
LogDebug
(
"Executed consumer method ."
);
}
}
}
finally
{
}
}
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP/Job/IJob.CapJob.cs
View file @
1f2716f9
...
@@ -40,6 +40,8 @@ namespace DotNetCore.CAP.Job
...
@@ -40,6 +40,8 @@ namespace DotNetCore.CAP.Job
var
nextReceivedMessage
=
await
messageStore
.
GetNextReceivedMessageToBeExcuted
();
var
nextReceivedMessage
=
await
messageStore
.
GetNextReceivedMessageToBeExcuted
();
if
(
nextReceivedMessage
!=
null
)
if
(
nextReceivedMessage
!=
null
)
{
try
{
{
var
executeDescriptor
=
matchs
[
nextReceivedMessage
.
KeyName
];
var
executeDescriptor
=
matchs
[
nextReceivedMessage
.
KeyName
];
var
consumerContext
=
new
ConsumerContext
(
executeDescriptor
,
nextReceivedMessage
);
var
consumerContext
=
new
ConsumerContext
(
executeDescriptor
,
nextReceivedMessage
);
...
@@ -49,7 +51,13 @@ namespace DotNetCore.CAP.Job
...
@@ -49,7 +51,13 @@ namespace DotNetCore.CAP.Job
await
invoker
.
InvokeAsync
();
await
invoker
.
InvokeAsync
();
await
messageStore
.
ChangeReceivedMessageStateAsync
(
nextReceivedMessage
,
StatusName
.
Succeeded
);
await
messageStore
.
ChangeReceivedMessageStateAsync
(
nextReceivedMessage
,
StatusName
.
Succeeded
);
}
catch
(
Exception
ex
)
{
_logger
.
ReceivedMessageRetryExecutingFailed
(
nextReceivedMessage
.
KeyName
,
ex
);
}
}
}
}
}
}
}
...
...
src/DotNetCore.CAP/LoggerExtensions.cs
View file @
1f2716f9
...
@@ -21,6 +21,7 @@ namespace DotNetCore.CAP
...
@@ -21,6 +21,7 @@ namespace DotNetCore.CAP
private
static
Action
<
ILogger
,
string
,
string
,
Exception
>
_enqueuingSentMessage
;
private
static
Action
<
ILogger
,
string
,
string
,
Exception
>
_enqueuingSentMessage
;
private
static
Action
<
ILogger
,
string
,
string
,
Exception
>
_enqueuingReceivdeMessage
;
private
static
Action
<
ILogger
,
string
,
string
,
Exception
>
_enqueuingReceivdeMessage
;
private
static
Action
<
ILogger
,
string
,
Exception
>
_executingConsumerMethod
;
private
static
Action
<
ILogger
,
string
,
Exception
>
_executingConsumerMethod
;
private
static
Action
<
ILogger
,
string
,
Exception
>
_receivedMessageRetryExecuting
;
static
LoggerExtensions
()
static
LoggerExtensions
()
{
{
...
@@ -78,6 +79,11 @@ namespace DotNetCore.CAP
...
@@ -78,6 +79,11 @@ namespace DotNetCore.CAP
LogLevel
.
Error
,
LogLevel
.
Error
,
5
,
5
,
"Consumer method '{methodName}' failed to execute."
);
"Consumer method '{methodName}' failed to execute."
);
_receivedMessageRetryExecuting
=
LoggerMessage
.
Define
<
string
>(
LogLevel
.
Error
,
5
,
"Received message topic method '{topicName}' failed to execute."
);
}
}
public
static
void
ConsumerMethodExecutingFailed
(
this
ILogger
logger
,
string
methodName
,
Exception
ex
)
public
static
void
ConsumerMethodExecutingFailed
(
this
ILogger
logger
,
string
methodName
,
Exception
ex
)
...
@@ -85,6 +91,11 @@ namespace DotNetCore.CAP
...
@@ -85,6 +91,11 @@ namespace DotNetCore.CAP
_executingConsumerMethod
(
logger
,
methodName
,
ex
);
_executingConsumerMethod
(
logger
,
methodName
,
ex
);
}
}
public
static
void
ReceivedMessageRetryExecutingFailed
(
this
ILogger
logger
,
string
topicName
,
Exception
ex
)
{
_receivedMessageRetryExecuting
(
logger
,
topicName
,
ex
);
}
public
static
void
EnqueuingReceivedMessage
(
this
ILogger
logger
,
string
nameKey
,
string
content
)
public
static
void
EnqueuingReceivedMessage
(
this
ILogger
logger
,
string
nameKey
,
string
content
)
{
{
_enqueuingReceivdeMessage
(
logger
,
nameKey
,
content
,
null
);
_enqueuingReceivdeMessage
(
logger
,
nameKey
,
content
,
null
);
...
...
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