Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
11d64f3c
Commit
11d64f3c
authored
Sep 09, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药明康德
parent
f477dea9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
server/app/Console/Commands/KafkaConsumerCommand.php
server/app/Console/Commands/KafkaConsumerCommand.php
+1
-0
server/app/Services/Kafka/KafkaService.php
server/app/Services/Kafka/KafkaService.php
+22
-0
No files found.
server/app/Console/Commands/KafkaConsumerCommand.php
View file @
11d64f3c
...
@@ -47,6 +47,7 @@ class KafkaConsumerCommand extends Command
...
@@ -47,6 +47,7 @@ class KafkaConsumerCommand extends Command
$consumer_type
=
$this
->
option
(
'type'
);
$consumer_type
=
$this
->
option
(
'type'
);
switch
(
$consumer_type
){
switch
(
$consumer_type
){
case
'zkh'
:
app
(
KafkaService
::
class
)
->
startZkhConsumer
();
break
;
case
'zkh'
:
app
(
KafkaService
::
class
)
->
startZkhConsumer
();
break
;
case
'wuxilab'
:
app
(
KafkaService
::
class
)
->
startWuxiLabConsumer
();
break
;
default
:
app
(
KafkaService
::
class
)
->
startConsumer
();
break
;
default
:
app
(
KafkaService
::
class
)
->
startConsumer
();
break
;
}
}
}
}
...
...
server/app/Services/Kafka/KafkaService.php
View file @
11d64f3c
...
@@ -99,6 +99,28 @@ class KafkaService
...
@@ -99,6 +99,28 @@ class KafkaService
$consumer
->
close
();
$consumer
->
close
();
}
}
/**
* 药明康德消费
*/
public
function
startWuxiLabConsumer
()
{
$this
->
config
[
'topic'
]
=
'wuxilab'
;
$this
->
kafkaConsumerConfig
=
$this
->
getConsumerConfig
(
$this
->
config
);
$consumer
=
new
Consumer
(
$this
->
kafkaConsumerConfig
,
function
(
ConsumeMessage
$message
)
{
try
{
$consumer
=
$message
->
getConsumer
();
$kafkaMessage
=
json_decode
(
$message
->
getValue
(),
true
);
$consumer
->
ack
(
$message
);
// 手动提交
app
(
$kafkaMessage
[
'consumer'
])
->
{
$kafkaMessage
[
'method'
]}(
$kafkaMessage
[
'params'
]);
}
catch
(
\Throwable
$exception
){
$this
->
errLog
(
$exception
,
$this
->
kafkaConsumerConfig
->
getGroupInstanceId
()
.
'_consumer'
);
}
$consumer
->
stop
();
});
$consumer
->
start
();
$consumer
->
close
();
}
protected
function
errLog
(
$exception
,
$errorType
)
protected
function
errLog
(
$exception
,
$errorType
)
{
{
SimpleLogs
::
writeLog
([
SimpleLogs
::
writeLog
([
...
...
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