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
8e107693
Commit
8e107693
authored
Oct 08, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename file.
parent
65e766f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
7 deletions
+43
-7
IProcessor.Failed.cs
src/DotNetCore.CAP/Processor/IProcessor.Failed.cs
+43
-7
No files found.
src/DotNetCore.CAP/Processor/IProcessor.Failed
Job
.cs
→
src/DotNetCore.CAP/Processor/IProcessor.Failed.cs
View file @
8e107693
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Infrastructure
;
using
DotNetCore.CAP.Internal
;
using
DotNetCore.CAP.Models
;
using
DotNetCore.CAP.Processor.States
;
using
Microsoft.Extensions.DependencyInjection
;
...
...
@@ -8,26 +11,32 @@ using Microsoft.Extensions.Options;
namespace
DotNetCore.CAP.Processor
{
public
class
Failed
Job
Processor
:
IProcessor
public
class
FailedProcessor
:
IProcessor
{
private
readonly
TimeSpan
_delay
=
TimeSpan
.
FromSeconds
(
1
);
private
readonly
ILogger
_logger
;
private
readonly
CapOptions
_options
;
private
readonly
IServiceProvider
_provider
;
private
readonly
IStateChanger
_stateChanger
;
private
readonly
ISubscriberExecutor
_subscriberExecutor
;
private
readonly
IPublishExecutor
_publishExecutor
;
private
readonly
TimeSpan
_waitingInterval
;
public
Failed
Job
Processor
(
public
FailedProcessor
(
IOptions
<
CapOptions
>
options
,
ILogger
<
Failed
Job
Processor
>
logger
,
ILogger
<
FailedProcessor
>
logger
,
IServiceProvider
provider
,
IStateChanger
stateChanger
)
IStateChanger
stateChanger
,
ISubscriberExecutor
subscriberExecutor
,
IPublishExecutor
publishExecutor
)
{
_options
=
options
.
Value
;
_logger
=
logger
;
_provider
=
provider
;
_stateChanger
=
stateChanger
;
_waitingInterval
=
TimeSpan
.
FromSeconds
(
_options
.
FailedMessageWaitingInterval
);
_subscriberExecutor
=
subscriberExecutor
;
_publishExecutor
=
publishExecutor
;
_waitingInterval
=
TimeSpan
.
FromSeconds
(
_options
.
FailedRetryInterval
);
}
public
async
Task
ProcessAsync
(
ProcessingContext
context
)
...
...
@@ -57,6 +66,9 @@ namespace DotNetCore.CAP.Processor
foreach
(
var
message
in
messages
)
{
if
(
message
.
Retries
>
_options
.
FailedRetryCount
)
continue
;
if
(!
hasException
)
try
{
...
...
@@ -70,7 +82,18 @@ namespace DotNetCore.CAP.Processor
using
(
var
transaction
=
connection
.
CreateTransaction
())
{
_stateChanger
.
ChangeState
(
message
,
new
EnqueuedState
(),
transaction
);
try
{
await
_publishExecutor
.
PublishAsync
(
message
.
Name
,
message
.
Content
);
_stateChanger
.
ChangeState
(
message
,
new
SucceededState
(),
transaction
);
}
catch
(
Exception
e
)
{
message
.
Content
=
Helper
.
AddExceptionProperty
(
message
.
Content
,
e
);
message
.
Retries
++;
transaction
.
UpdateMessage
(
message
);
}
await
transaction
.
CommitAsync
();
}
...
...
@@ -87,6 +110,9 @@ namespace DotNetCore.CAP.Processor
foreach
(
var
message
in
messages
)
{
if
(
message
.
Retries
>
_options
.
FailedRetryCount
)
continue
;
if
(!
hasException
)
try
{
...
...
@@ -100,7 +126,17 @@ namespace DotNetCore.CAP.Processor
using
(
var
transaction
=
connection
.
CreateTransaction
())
{
_stateChanger
.
ChangeState
(
message
,
new
EnqueuedState
(),
transaction
);
var
ret
=
await
_subscriberExecutor
.
ExecuteAsync
(
message
);
if
(
ret
.
Succeeded
)
{
_stateChanger
.
ChangeState
(
message
,
new
SucceededState
(),
transaction
);
}
else
{
message
.
Retries
++;
message
.
Content
=
Helper
.
AddExceptionProperty
(
message
.
Content
,
ret
.
Exception
);
transaction
.
UpdateMessage
(
message
);
}
await
transaction
.
CommitAsync
();
}
...
...
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