queue

Is RabbitMQ capable of “pushing” messages from a queue to a consumer?

白昼怎懂夜的黑 提交于 2020-01-21 04:22:22
问题 With RabbitMQ, is there a way to "push" messages from a queue TO a consumer as opposed to having a consumer "poll and pull" messages FROM a queue? This has been the cause of some debate on a current project i'm on. The argument from one side is that having consumers (i.e. a windows service) "poll" a queue until a new message arrives is somewhat inefficient and less desirable than the idea having the message "pushed" automatically from the queue to the subscriber(s)/consumer(s). I can only

PHP How do I implement queue processing in php

你说的曾经没有我的故事 提交于 2020-01-19 20:27:06
问题 I want the data sent by my clients (via post) to be placed in a queue and a php script on my server first checks if the queue is empty. If the queue is not empty, then the script shall process all the data in the queue one by one.How do I do this? 回答1: You could use something like Zero MQ See Example by Rasmus Lerdorf. You could also consider using Gearman to distribute the load. 回答2: This is something you could easily do with enqueue library. First, you can choose from a variety of

Why are Stack<T> and Queue<T> implemented with an array?

喜欢而已 提交于 2020-01-19 00:42:06
问题 I'm reading C# 4.0 in a Nutshell by the Albahari brothers and I came across this: Stacks are implemented internally with an array that's resized as required , as with Queue and List. (pg 288, paragraph 4) I can't help but wonder why. LinkedList provides O(1) head and tail inserts and deletes (which should work well for a stack or queue). A resizable array has O(1) amortized insert (if I remember right), but O(n) worst case (I'm not sure about delete). And it probably uses more space than the

Problem in resque: job not getting removed from queue when finished processing

落爺英雄遲暮 提交于 2020-01-16 18:02:34
问题 I am using resque, and resque-scheduler in my rails application. I am facing strange problem in using resque-scheduler. One of my job is not getting removed from queue, once it finishes with the 'perform' method. I need to kill it explicitly to get out of the queue, then other jobs in the queue starts executing. Job class is simple, like: class FooJob @queue = :high_volume def self.perform puts "FooJob#perform:" # some method call end end And resque_schedule.yml contains: add_jobs_from_foo:

Capacity Provisioning for Server Farms

浪子不回头ぞ 提交于 2020-01-16 17:07:52
问题 Suppose I have N M/M/1 queues in parallel where an arriving job is equally likely to join one of the N queues. We want to keep the probability for a job to wait less than 0.2. Given that we have an arrival rate of 400 jobs/second, and a processing times are exponentially distributed with mean 1 second, how many servers would be required? So my take on the question so far is: \lambda = 400 jobs/second \mu = 1 second \rho = (\lambda)/(k\mu) since we want to keep the probability of waiting less

Multi size queue without malloc

岁酱吖の 提交于 2020-01-16 03:28:05
问题 I am interested in build a queue that could receive different but defined sizes. Let's say, with 8, 16 and 32 elements and I want to do it without use malloc. Well, it would be easy if I create 3 different queues but I don't want to do this, I want to use the same functions and just define the three types. My problem is exactly this, I have three places in my code that I would like to use a queue, but those cases would use queues with different sizes and I know what size it is. I don't want

Perl fork queue for n-Core processor

时光总嘲笑我的痴心妄想 提交于 2020-01-15 23:03:07
问题 I am writing an application similar to what was suggested here. Essentially, I am using Perl to manage the execution of multiple CPU intensive processes in parallel via fork and wait. However, I am running on a 4-core machine, and I have many more processes, all with very dissimilar expected run-times which aren't known a priori. Ultimately, it would take more effort to estimate the run times and gang them appropriately, than to simply utilize a queue system for each core. Ultimately I want

Thread safe Map of Queues

不羁岁月 提交于 2020-01-15 12:24:28
问题 I want to implement a thread safe Map of Queues. I intent to start with an empty Map. If the key does not exist, I want to create a new Map entry with a new Queue. If the key does exist, I want to add to the Queue. My proposed implementation is as follows: import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; public class StackOverFlowExample { private final Map<String, ConcurrentLinkedQueue<String>> map = new ConcurrentHashMap

How to build an email queue with PHPmailer?

狂风中的少年 提交于 2020-01-15 11:54:54
问题 I have built an emailing script with PHPmailer after inserting into a table, however, I'm getting a bad gateway 502 coz the script times out. and sending 300+ emails in response to a web request doesn't sound like a good idea to me. So my question is how can I build a queue that will send the emails in the background? as far as I understand I will need new table lets say email_queue_table insert the email addresses, content and then have a field called status sent or queued create a while

Thread-safe async byte queue

こ雲淡風輕ζ 提交于 2020-01-14 19:15:20
问题 I've got a callback method that is called whenever new data is available: public delegate void DataCallback( byte[] buffer, int offset, int count); I want to wrap this in a class that implements an interface similar to this: public interface IDataSource { IAsyncResult BeginRead( byte[] buffer, int offset, int size, TimeSpan timeout, AsyncCallback callback, object state); int EndRead( IAsyncResult asyncResult); int Read( byte[] buffer, int offset, int size, TimeSpan timeout); } This is