我正在寻找一个队列系统,其中多个不同的订户可以从集中队列中提取项目.消息将非常轻量级,但我需要一些持久且非常快的消息,因为消息量很大.MSMQ有点沉重,我正在寻找一些轻松的东西.建议?
我不得不构建一个PHP Queue System,并发现了这篇精彩的文章
,我用它来创建一个PHP队列系统,它非常容易设置和使用.http://squirrelshaterobots.com/programming/php/building-a-queue-server-in-php-part-1-understanding-the-project
下面是queue.php的代码,从shell(puTTy或somesuch)运行.
<?PHP
//. set this constant to false if we ever need to debug
//. the application in a terminal.
define('QUEUESERVER_FORK', true);
//////// fork into a background process ////////
if(QUEUESERVER_FORK){
$pid = pcntl_fork();
if($pid === -1) die('error: unable to fork.');
else if($pid) exit(0);
posix_setsid();
sleep(1);
ob_start();
}
$queue = array();
//////// setup our named pipe ////////
$pipefile = '/tmp/queueserver-input';
if(file_exists($pipefile))
if(!unlink($pipefile))
die('unable to remove stale file');
umask(0);
if(!posix_mkfifo($pipefile, 0666))
die('unable to create named pipe'); …Run Code Online (Sandbox Code Playgroud) 我正试图std::vector在我的项目中寻找替代品,我发现这std::queue就是我正在寻找的东西.
我有很多range-based loop用于迭代的函数,我试图尽可能地维护它.
我尝试编译一个range-based loopin std::queue但我得到的只是编译错误
错误:没有匹配函数来调用'begin(std :: queue&)'
不std::queue支持范围基本循环?
我确实尝试过,Google search但没有找到任何有关此问题的话题.
更新:
我的编译器是 GCC v4.7.1
-std=c++11 已启用
这是错误的测试代码:
std::queue<int> Q;
for (int i = 0;i < 10; ++i)
Q.push(i);
std::cout << "\nqueue contains: ";
for (auto i : Q)
std::cout << i << ", ";
Run Code Online (Sandbox Code Playgroud) 我需要在Delphi中创建一个具有以下特征的线程:
我无法向线程发送消息,因为它没有窗口句柄.
我应该使用WaitForObject的某些变体吗?如果是这样,等待的是什么?如果没有,那么我如何保持线程等待,然后在新数据进入队列时唤醒它?
我读过Multithreading - Delphi Way,它似乎没有回答我的问题.也许 OmniThreadLibrary可以做我需要的事情; 我无法分辨,因为文档很少.我不太了解一般的线程,以确定库是否会在这里提供帮助以及如何使用它(甚至为什么要使用它而不是仅使用TThread后代).
我在想,当多个线程正在读写时,是否有可能拥有无锁队列?我已经看到了一个带有无锁队列的实现,它可以使用一个读取线程和一个写入线程但不会超过一个.可能吗?我认为不是.可以/有人想要证明吗?
看到java是如此成熟,我希望有人能告诉我java是否有类似于http://celeryproject.org/的内容
它是一个分布式任务队列.
我正在给rabbitmq写信,想知道除了芹菜之外还有什么选择.
using System.Collections.Generic;
public sealed class LoLQueue<T> where T: class
{
private SingleLinkNode<T> mHe;
private SingleLinkNode<T> mTa;
public LoLQueue()
{
this.mHe = new SingleLinkNode<T>();
this.mTa = this.mHe;
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
The non-generic type 'LoLQueue<T>.SingleLinkNode' cannot be used with type arguments
Run Code Online (Sandbox Code Playgroud)
为什么我会这样?
基本上我的消费者也是生产者.我们得到一个初始数据集,然后将其发送到队列.消费者接受物品并对其进行处理,从那时起有3种可能性:
我的问题在于第3步,因为队列起初非常快,可能会将一段数据分解为队列中重复的部分,并且消费者继续处理它并最终进入无限循环.
我认为防止这种情况的方法是防止重复进入队列.我不能在客户端做到这一点,因为在一个小时的过程中,我可能会有许多核心处理数十亿个数据点(让每个客户端在提交之前对其进行扫描会使我的速度减慢太多).我认为这需要在服务器端完成,但是,正如我所提到的,数据非常大,我不知道如何有效地确保没有重复.
我可能会问不可能,但我想我会试一试.任何想法将不胜感激.
我正在写一段代码,这将允许我们:
前2分我没有问题; 使用Peek接收模式,我可以显示消息列表,我们可以编辑和重新发送,没有任何问题.
当我想从死信队列中删除消息时,问题就来了.
我们如何通过消息级别对消息执行此操作?我们可能只想删除驻留在死信队列中的2条消息,并保留其他消息以便稍后查看.调用.Complete()死信队列中的消息是否像在主订阅中那样删除它?
以供参考; 这是我们获取SubscriptionClient死信队列的代码:
private SubscriptionClient GetOrCreateSubscriptionClient(string connectionString)
{
if (!NamespaceManager.TopicExists(_topicName))
{
NamespaceManager.CreateTopic(new TopicDescription(_topicName)
{
MaxSizeInMegabytes = 5120,
DefaultMessageTimeToLive = TimeSpan.FromSeconds(DEFAULT_LOCK_DURATION_IN_SECONDS)
});
}
if (!NamespaceManager.SubscriptionExists(_topicName, _subscriptionName))
{
NamespaceManager.CreateSubscription(_topicName, _subscriptionName);
}
var deadLetterPath = SubscriptionClient.FormatDeadLetterPath(_topicName, _subscriptionName);
var client = SubscriptionClient.CreateFromConnectionString(
connectionString, deadLetterPath, _subscriptionName, ReceiveMode.PeekLock);
return client;
}
Run Code Online (Sandbox Code Playgroud) 这些实现之间有什么区别,哪些情况应该使用一个或另一个队列?