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
83064c25
Commit
83064c25
authored
Jul 06, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify job processor executor step.
parent
ea2cf5f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
39 deletions
+29
-39
IProcessor.RabbitJobProcessor.cs
src/DotNetCore.CAP.RabbitMQ/IProcessor.RabbitJobProcessor.cs
+29
-39
No files found.
src/DotNetCore.CAP.RabbitMQ/IProcessor.RabbitJobProcessor.cs
View file @
83064c25
...
@@ -81,37 +81,35 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -81,37 +81,35 @@ namespace DotNetCore.CAP.RabbitMQ
{
{
var
provider
=
scopedContext
.
Provider
;
var
provider
=
scopedContext
.
Provider
;
var
messageStore
=
provider
.
GetRequiredService
<
ICapMessageStore
>();
var
messageStore
=
provider
.
GetRequiredService
<
ICapMessageStore
>();
var
message
=
await
messageStore
.
GetNextSentMessageToBeEnqueuedAsync
();
try
try
{
{
var
message
=
await
messageStore
.
GetNextSentMessageToBeEnqueuedAsync
();
if
(
message
!=
null
)
if
(
message
!=
null
)
{
{
var
sp
=
Stopwatch
.
StartNew
();
var
sp
=
Stopwatch
.
StartNew
();
message
.
StatusName
=
StatusName
.
Processing
;
message
.
StatusName
=
StatusName
.
Processing
;
await
messageStore
.
UpdateSentMessageAsync
(
message
);
await
messageStore
.
UpdateSentMessageAsync
(
message
);
var
jobResult
=
ExecuteJob
(
message
.
KeyName
,
message
.
Content
);
ExecuteJob
(
message
.
KeyName
,
message
.
Content
);
sp
.
Stop
();
sp
.
Stop
();
if
(
jobResult
)
message
.
StatusName
=
StatusName
.
Succeeded
;
{
await
messageStore
.
UpdateSentMessageAsync
(
message
);
await
messageStore
.
RemoveSentMessageAsync
(
message
);
_logger
.
JobExecuted
(
sp
.
Elapsed
.
TotalSeconds
);
_logger
.
JobExecuted
(
sp
.
Elapsed
.
TotalSeconds
);
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
)
{
{
_logger
.
ExceptionOccuredWhileExecutingJob
(
message
.
KeyName
,
ex
);
return
false
;
return
false
;
}
}
}
}
return
true
;
return
true
;
}
}
private
bool
ExecuteJob
(
string
topic
,
string
content
)
private
void
ExecuteJob
(
string
topic
,
string
content
)
{
try
{
{
var
factory
=
new
ConnectionFactory
()
var
factory
=
new
ConnectionFactory
()
{
{
...
@@ -135,14 +133,6 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -135,14 +133,6 @@ namespace DotNetCore.CAP.RabbitMQ
routingKey
:
topic
,
routingKey
:
topic
,
basicProperties
:
null
,
basicProperties
:
null
,
body
:
body
);
body
:
body
);
return
true
;
}
}
catch
(
Exception
ex
)
{
_logger
.
ExceptionOccuredWhileExecutingJob
(
topic
,
ex
);
return
false
;
}
}
}
}
}
}
...
...
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