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
52ec7934
Commit
52ec7934
authored
Aug 01, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add failed call back.
parent
a369ad96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
IProcessor.FailedJob.cs
src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs
+36
-0
No files found.
src/DotNetCore.CAP/Processor/IProcessor.FailedJob.cs
View file @
52ec7934
...
@@ -53,14 +53,32 @@ namespace DotNetCore.CAP.Processor
...
@@ -53,14 +53,32 @@ namespace DotNetCore.CAP.Processor
private
async
Task
ProcessPublishedAsync
(
IStorageConnection
connection
,
ProcessingContext
context
)
private
async
Task
ProcessPublishedAsync
(
IStorageConnection
connection
,
ProcessingContext
context
)
{
{
var
messages
=
await
connection
.
GetFailedPublishedMessages
();
var
messages
=
await
connection
.
GetFailedPublishedMessages
();
var
hasException
=
false
;
foreach
(
var
message
in
messages
)
foreach
(
var
message
in
messages
)
{
{
if
(!
hasException
)
{
try
{
_options
.
FailedCallback
?.
Invoke
(
Models
.
MessageType
.
Publish
,
message
.
Name
,
message
.
Content
);
}
catch
(
Exception
ex
)
{
hasException
=
true
;
_logger
.
LogWarning
(
"Failed call-back method raised an exception:"
+
ex
.
Message
);
}
}
using
(
var
transaction
=
connection
.
CreateTransaction
())
using
(
var
transaction
=
connection
.
CreateTransaction
())
{
{
_stateChanger
.
ChangeState
(
message
,
new
EnqueuedState
(),
transaction
);
_stateChanger
.
ChangeState
(
message
,
new
EnqueuedState
(),
transaction
);
await
transaction
.
CommitAsync
();
await
transaction
.
CommitAsync
();
}
}
context
.
ThrowIfStopping
();
context
.
ThrowIfStopping
();
await
context
.
WaitAsync
(
_delay
);
await
context
.
WaitAsync
(
_delay
);
}
}
}
}
...
@@ -68,14 +86,32 @@ namespace DotNetCore.CAP.Processor
...
@@ -68,14 +86,32 @@ namespace DotNetCore.CAP.Processor
private
async
Task
ProcessReceivededAsync
(
IStorageConnection
connection
,
ProcessingContext
context
)
private
async
Task
ProcessReceivededAsync
(
IStorageConnection
connection
,
ProcessingContext
context
)
{
{
var
messages
=
await
connection
.
GetFailedReceviedMessages
();
var
messages
=
await
connection
.
GetFailedReceviedMessages
();
var
hasException
=
false
;
foreach
(
var
message
in
messages
)
foreach
(
var
message
in
messages
)
{
{
if
(!
hasException
)
{
try
{
_options
.
FailedCallback
?.
Invoke
(
Models
.
MessageType
.
Subscribe
,
message
.
Name
,
message
.
Content
);
}
catch
(
Exception
ex
)
{
hasException
=
true
;
_logger
.
LogWarning
(
"Failed call-back method raised an exception:"
+
ex
.
Message
);
}
}
using
(
var
transaction
=
connection
.
CreateTransaction
())
using
(
var
transaction
=
connection
.
CreateTransaction
())
{
{
_stateChanger
.
ChangeState
(
message
,
new
EnqueuedState
(),
transaction
);
_stateChanger
.
ChangeState
(
message
,
new
EnqueuedState
(),
transaction
);
await
transaction
.
CommitAsync
();
await
transaction
.
CommitAsync
();
}
}
context
.
ThrowIfStopping
();
context
.
ThrowIfStopping
();
await
context
.
WaitAsync
(
_delay
);
await
context
.
WaitAsync
(
_delay
);
}
}
}
}
...
...
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