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
3d7eb4bc
Commit
3d7eb4bc
authored
Jun 29, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change exhcange type with options.
parent
725b4677
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
22 deletions
+14
-22
IProcessor.RabbitJobProcessor.cs
src/DotNetCore.CAP.RabbitMQ/IProcessor.RabbitJobProcessor.cs
+5
-12
RabbitMQConsumerClient.cs
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
+9
-10
No files found.
src/DotNetCore.CAP.RabbitMQ/IProcessor.RabbitJobProcessor.cs
View file @
3d7eb4bc
...
@@ -94,16 +94,9 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -94,16 +94,9 @@ namespace DotNetCore.CAP.RabbitMQ
sp
.
Stop
();
sp
.
Stop
();
if
(
!
jobResult
)
if
(
jobResult
)
{
{
_logger
.
JobFailed
(
new
Exception
(
"topic send failed"
));
await
messageStore
.
RemoveSentMessageAsync
(
message
);
}
else
{
//TODO : the state will be deleted when release.
message
.
StatusName
=
StatusName
.
Succeeded
;
await
messageStore
.
UpdateSentMessageAsync
(
message
);
_logger
.
JobExecuted
(
sp
.
Elapsed
.
TotalSeconds
);
_logger
.
JobExecuted
(
sp
.
Elapsed
.
TotalSeconds
);
}
}
}
}
...
@@ -135,10 +128,10 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -135,10 +128,10 @@ namespace DotNetCore.CAP.RabbitMQ
using
(
var
connection
=
factory
.
CreateConnection
())
using
(
var
connection
=
factory
.
CreateConnection
())
using
(
var
channel
=
connection
.
CreateModel
())
using
(
var
channel
=
connection
.
CreateModel
())
{
{
channel
.
ExchangeDeclare
(
exchange
:
"test"
,
type
:
"topic"
);
var
body
=
Encoding
.
UTF8
.
GetBytes
(
content
);
var
body
=
Encoding
.
UTF8
.
GetBytes
(
content
);
channel
.
BasicPublish
(
exchange
:
"test"
,
channel
.
ExchangeDeclare
(
_rabbitMQOptions
.
TopicExchangeName
,
_rabbitMQOptions
.
EXCHANGE_TYPE
);
channel
.
BasicPublish
(
exchange
:
_rabbitMQOptions
.
TopicExchangeName
,
routingKey
:
topic
,
routingKey
:
topic
,
basicProperties
:
null
,
basicProperties
:
null
,
body
:
body
);
body
:
body
);
...
...
src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
View file @
3d7eb4bc
...
@@ -9,10 +9,8 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -9,10 +9,8 @@ namespace DotNetCore.CAP.RabbitMQ
{
{
public
class
RabbitMQConsumerClient
:
IConsumerClient
public
class
RabbitMQConsumerClient
:
IConsumerClient
{
{
public
const
string
TYPE
=
"topic"
;
private
readonly
string
_exchageName
;
private
readonly
string
_queueName
;
private
string
_queueName
;
private
readonly
string
_exchange
;
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
private
readonly
RabbitMQOptions
_rabbitMQOptions
;
private
IConnectionFactory
_connectionFactory
;
private
IConnectionFactory
_connectionFactory
;
...
@@ -21,10 +19,11 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -21,10 +19,11 @@ namespace DotNetCore.CAP.RabbitMQ
public
event
EventHandler
<
MessageBase
>
MessageReceieved
;
public
event
EventHandler
<
MessageBase
>
MessageReceieved
;
public
RabbitMQConsumerClient
(
string
exchang
e
,
RabbitMQOptions
options
)
public
RabbitMQConsumerClient
(
string
queueNam
e
,
RabbitMQOptions
options
)
{
{
_
exchange
=
exchang
e
;
_
queueName
=
queueNam
e
;
_rabbitMQOptions
=
options
;
_rabbitMQOptions
=
options
;
_exchageName
=
options
.
TopicExchangeName
;
InitClient
();
InitClient
();
}
}
...
@@ -45,8 +44,8 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -45,8 +44,8 @@ namespace DotNetCore.CAP.RabbitMQ
_connection
=
_connectionFactory
.
CreateConnection
();
_connection
=
_connectionFactory
.
CreateConnection
();
_channel
=
_connection
.
CreateModel
();
_channel
=
_connection
.
CreateModel
();
_channel
.
ExchangeDeclare
(
exchange
:
_excha
nge
,
type
:
TYPE
);
_channel
.
ExchangeDeclare
(
exchange
:
_excha
geName
,
type
:
_rabbitMQOptions
.
EXCHANGE_
TYPE
);
_
queueName
=
_channel
.
QueueDeclare
().
QueueName
;
_
channel
.
QueueDeclare
(
_queueName
)
;
}
}
public
void
Listening
(
TimeSpan
timeout
)
public
void
Listening
(
TimeSpan
timeout
)
...
@@ -62,12 +61,12 @@ namespace DotNetCore.CAP.RabbitMQ
...
@@ -62,12 +61,12 @@ namespace DotNetCore.CAP.RabbitMQ
public
void
Subscribe
(
string
topic
)
public
void
Subscribe
(
string
topic
)
{
{
_channel
.
QueueBind
(
_queueName
,
_excha
ng
e
,
topic
);
_channel
.
QueueBind
(
_queueName
,
_excha
geNam
e
,
topic
);
}
}
public
void
Subscribe
(
string
topic
,
int
partition
)
public
void
Subscribe
(
string
topic
,
int
partition
)
{
{
_channel
.
QueueBind
(
_queueName
,
_excha
ng
e
,
topic
);
_channel
.
QueueBind
(
_queueName
,
_excha
geNam
e
,
topic
);
}
}
public
void
Dispose
()
public
void
Dispose
()
...
...
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