Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
汪标炎
base-tool
Commits
df9de770
Commit
df9de770
authored
8 months ago
by
wangbiaoyan
Browse files
Options
Download
Patches
Plain Diff
新增消费方法
parent
f1319750
master
v1.2.9
v1.2.8
v1.2.7
v1.2.6
v1.2.5
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Mq/MqConsumeInterface.php
+39
-0
src/Mq/MqConsumeInterface.php
with
39 additions
and
0 deletions
+39
-0
src/Mq/MqConsumeInterface.php
+
39
−
0
View file @
df9de770
...
...
@@ -42,6 +42,12 @@ abstract class MqConsumeInterface
{
}
/**
* 版本号
* @var string $version
*/
protected
$version
=
""
;
/**
* 消费后置动作
* @return mixed
...
...
@@ -108,4 +114,37 @@ abstract class MqConsumeInterface
}
}
}
public
function
handleConsumeV1
()
{
$params
=
[
"exchangeName"
=>
$this
->
exchangeName
,
"exchangeType"
=>
$this
->
exchangeType
,
"queueName"
=>
$this
->
queueName
,
"routeKey"
=>
$this
->
routeKey
,
"callback"
=>
[
$this
,
"consumeCallback"
],
"object"
=>
$this
];
$consumeParamBean
=
new
ConsumeParamBean
(
$params
);
switch
(
config
(
"queue.connections.default"
))
{
case
"rabbitmq"
:
$rabbitMq
=
RabbitMq
::
getInstance
();
//声明交换机
$rabbitMq
->
declareExchange
(
$consumeParamBean
->
getExchangeName
(),
$consumeParamBean
->
getExchangeType
());
//声明队列
$rabbitMq
->
declareQueue
(
$consumeParamBean
->
getQueueName
(),
$consumeParamBean
->
getRouteKey
());
break
;
default
:
throw
new
MqException
(
"未知消息队列"
);
}
while
(
true
)
{
try
{
$rabbitMq
->
getQueue
()
->
consume
([
$this
,
"consumeCallback"
]);
}
catch
(
\
Throwable
$exception
)
{
$this
->
exceptionHandle
(
$exception
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets