Skip to content

Commit

Permalink
V4.1.x (#40)
Browse files Browse the repository at this point in the history
* optimization log

* Compatible with docker in the same data volume

* fixed: return bool bug
  • Loading branch information
kcloze authored Sep 30, 2019
1 parent d4b4136 commit f68f75d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Queue/RabbitmqTopicQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function push($topic, JobObject $job, $delayStrategy=1, $serializeFunc='p
}

$queue = $this->createQueue($topic);
if (!is_object($queue)) {
if (!\is_object($queue)) {
//对象有误 则直接返回空
return '';
}
Expand Down Expand Up @@ -138,23 +138,23 @@ public function pop($topic, $unSerializeFunc='php')
}
//reset consumer and message properties
$this->consumer=null;
$this->message=null;
$this->message =null;

$queue = $this->createQueue($topic);
$consumer = $this->context->createConsumer($queue);

if ($m = $consumer->receive(1)) {
$result =$m->getBody();
$this->consumer =$consumer;
$this->message =$m;
$this->message =$m;
//判断字符串是否是php序列化的字符串,目前只允许serialzie和json两种
$unSerializeFunc=Serialize::isSerial($result) ? 'php' : 'json';

return !empty($result) ? Serialize::unserialize($result, $unSerializeFunc) : null;
}
}

public function ack(): boolean
public function ack(): bool
{
if ($this->consumer && $this->message) {
$this->consumer->acknowledge($this->message);
Expand All @@ -174,7 +174,7 @@ public function len($topic): int
}

$queue = $this->createQueue($topic);
if (!is_object($queue)) {
if (!\is_object($queue)) {
//对象有误 则直接返回空
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/RedisTopicQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function pop($topic, $unSerializeFunc='php')
}

//redis不支持ack功能,搞个假的,没办法
public function ack(): boolean
public function ack(): bool
{
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Queue/TopicQueueInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public function push($topic, JobObject $job): string;
*/
public function pop($topic);

/**
* ack确认消息
*/
public function ack(): boolean;
/**
* ack确认消息.
*/
public function ack(): bool;

/**
* @param $topic
Expand Down

0 comments on commit f68f75d

Please sign in to comment.