我们在Spring Web应用程序中使用了redis list并使用了lpush / rpop命令,并期望它表现为FIFO队列。但它不是!它会从列表中弹出一个随机元素。您可以在以下的lrange输出中看到。
127.0.0.1:6379> lrange word_getprice_queue:2520e2df-6771-4ee0-8cea-f6b2c68019b3 0 -1
1) "ef682e35-aea8-4cb4-bd32-26b52d7943e0"
2) "83f4ff87-0a8e-4631-8f2c-7785b298077b"
3) "99fdb591-d2ed-4bef-b85e-38ee42dbe8ef"
4) "9527ca7e-b6e7-4d7f-93c2-d3b59bb1aacc"
5) "4ad6a66e-c727-4373-8e81-82e330adba92"
6) "23f201b4-02c6-4385-9080-bd0a6b21bdc8"
7) "3c9b6876-e3ba-481a-8012-f0b364830bfd"
8) "0c00e8f6-5de4-4685-bee1-cec4eca4b546"
9) "bb6b87b0-05e9-4a8b-9617-060f32963f68"
10) "1048e02f-0bbd-4130-b94e-ab658d77d7c6"
127.0.0.1:6379> lrange word_getprice_queue:2520e2df-6771-4ee0-8cea-f6b2c68019b3 0 -1
1) "3c9b6876-e3ba-481a-8012-f0b364830bfd"
2) "0c00e8f6-5de4-4685-bee1-cec4eca4b546"
3) "bb6b87b0-05e9-4a8b-9617-060f32963f68"
4) "1048e02f-0bbd-4130-b94e-ab658d77d7c6"
5) "ef682e35-aea8-4cb4-bd32-26b52d7943e0"
6) "83f4ff87-0a8e-4631-8f2c-7785b298077b"
7) "99fdb591-d2ed-4bef-b85e-38ee42dbe8ef"
8) "9527ca7e-b6e7-4d7f-93c2-d3b59bb1aacc"
9) "4ad6a66e-c727-4373-8e81-82e330adba92"
127.0.0.1:6379> lrange word_getprice_queue:2520e2df-6771-4ee0-8cea-f6b2c68019b3 0 -1
1) "bb6b87b0-05e9-4a8b-9617-060f32963f68"
2) "1048e02f-0bbd-4130-b94e-ab658d77d7c6"
3) "ef682e35-aea8-4cb4-bd32-26b52d7943e0"
4) "83f4ff87-0a8e-4631-8f2c-7785b298077b"
5) "99fdb591-d2ed-4bef-b85e-38ee42dbe8ef"
6) "9527ca7e-b6e7-4d7f-93c2-d3b59bb1aacc"
7) "3c9b6876-e3ba-481a-8012-f0b364830bfd"
8) "0c00e8f6-5de4-4685-bee1-cec4eca4b546"
我已将redis更新为3.0.7,将jedis更新为2.4.2,但没有运气。
TaskPusherGetPriceWord,TaskGet5Price,TaskPusherWordCount是三个弹簧计划任务。 TaskPusherGetPriceWord将一些单词推入队列,TaskGet5Price从队列中弹出这些单词,如果发生某事,TaskPusherWordCount就会清空队列。您可以从上图中看到所有调用项目中操作队列的调用。
<task:scheduled-tasks>
<task:scheduled ref="taskPusherGetPriceWord" method="doTask" fixed-delay="300000" />
</task:scheduled-tasks>
<task:scheduled-tasks>
<task:scheduled ref="taskGet5Price" method="doTask" fixed-delay="5" />
</task:scheduled-tasks>
<task:scheduled-tasks>
<task:scheduled ref="taskPusherWordCount" method="doTask" fixed-delay="60000" />
</task:scheduled-tasks>