试图将 Pheanstalk 包装在我的 PHP 作业基类中。我正在测试具有延迟功能的保留和保留,我发现我可以从我的基类的第二个实例中保留一个作业,而无需第一个实例释放作业或 TTR 超时。这是出乎意料的,因为我认为这正是作业队列应该防止的事情。这是第一个 put 和第一个保留的 beanstalkd 命令以及时间戳。最后我还做了一个 stats-job 请求:
01:40:15: Sending command: use QueuedCoreEvent
01:40:15: Got response: USING QueuedCoreEvent
01:40:15: Sending command: put 1024 0 300 233
a:4:{s:9:"eventName";s:21:"ReQueueJob_eawu7xr9bi";s:6:"params";a:2:{s:12:"InstanceName";s:21:"ReQueueJob_eawu7xr9bi";s:17:"aValueToIncrement";i:123456;}s:9:"behaviors";a:1:{i:0;s:22:"BehMCoreEventTestDummy";}s:12:"failureCount";i:0;}
01:40:15: Got response: INSERTED 10
01:40:15: Sending command: watch QueuedCoreEvent
01:40:15: Got response: WATCHING 2
01:40:15: Sending command: ignore default
01:40:15: Got response: WATCHING 1
01:40:15: Sending command: reserve-with-timeout 0
01:40:15: Got response: RESERVED 10 233
01:40:15: Data: a:4:{s:9:"eventName";s:21:"ReQueueJob_eawu7xr9bi";s:6:"params";a:2:{s:12:"InstanceName";s:21:"ReQueueJob_eawu7xr9bi";s:17:"aValueToIncrement";i:123456;}s:9:"behaviors";a:1:{i:0;s:22:"BehMCoreEventTestDummy";}s:12:"failureCount";i:0;}
01:40:15: Sending command: stats-job 10
01:40:15: Got response: OK 162
01:40:15: Data: ---
id: 10
tube: QueuedCoreEvent
state: reserved
pri: 1024
age: 0
delay: 0
ttr: 300
time-left: 299
file: 0
reserves: 1
timeouts: 0
releases: 0
buries: 0
kicks: 0
到目前为止,一切都很好。现在我从我的基类的第二个实例做另一个储备,然后是另一个统计作业请求。请注意,时间戳在同一秒内,与我设置的 300 秒 TTR 相去甚远。另请注意,在第二个 stats-job 打印输出中,该作业有 2 个保留,其中 0 个超时和 0 个释放。
01:40:15: Sending command: watch QueuedCoreEvent
01:40:15: Got response: WATCHING 2
01:40:15: Sending command: ignore default
01:40:15: Got response: WATCHING 1
01:40:15: Sending command: reserve-with-timeout 0
01:40:15: Got response: RESERVED 10 233
01:40:15: Data: a:4:{s:9:"eventName";s:21:"ReQueueJob_eawu7xr9bi";s:6:"params";a:2:{s:12:"InstanceName";s:21:"ReQueueJob_eawu7xr9bi";s:17:"aValueToIncrement";i:123456;}s:9:"behaviors";a:1:{i:0;s:22:"BehMCoreEventTestDummy";}s:12:"failureCount";i:0;}
01:40:15: Sending command: stats-job 10
01:40:15: Got response: OK 162
01:40:15: Data: ---
id: 10
tube: QueuedCoreEvent
state: reserved
pri: 1024
age: 0
delay: 0
ttr: 300
time-left: 299
file: 0
reserves: 2
timeouts: 0
releases: 0
buries: 0
kicks: 0
有人对我可能做错了什么有任何想法吗?我需要做些什么来告诉队列我希望作业一次只能由一名工作人员访问吗?一旦我将工作从队列中取出,我就会在 pheanstalk 实例上进行“取消设置”,我相信这会终止与 beanstalkd 的会话。这是否会导致 beanstalkd 决定工人已经死亡并自动释放工作而没有超时?我不确定 beanstalkd 有多少依赖会话状态来确定工作状态。我假设我可以不受惩罚地打开和关闭会话,并且工作 ID 是 beanstalkd 唯一关心的将工作操作联系在一起的东西,但这对我来说可能是愚蠢的......这是我第一次涉足工作队列.
谢谢!