#127
No matter who you are, you can always learn something from someone else, no matter who they are.

How to queue a class method with delayed job

Ok, so you have a project using Delayed Job but need to queue a class method. But oh no! You can't queue a class method because of either "ArgumentError: Cannot enqueue items which do not respond to perform" or "TypeError: can't dump anonymous class Class". What do you do now?

The simple and clean solution: use Resque [1] instead. It scales a lot better and doesn't put extra overhead on your database. Seriously consider for a moment that each delayed job worker is querying the database once every second...the same database that your application is probably using to load its models. Resque offsets that by using a fast keystore database separate from the other models (unless you're using redis models, but if you do that then ... haha?). But for those of you who can't use resque for one reason or another, here's a little piece of code that will give something similar.

[1] I don't like how resque is supposed to be pronounced like rescue, it should be pronounced like resk.
Kia Kroas :=: 17 Dec, 2010 02:14:02


This code can be used for example to queue your ActionMailer model's deliver_* methods. I know there are some hacks out there that try to make ActionMailer play nice with DelayedJob but they don't particularly seem like pleasing hacks. They overshoot too much by trying to get Delayed Job to work specifically with ActionMailer rather than doing the general solution that would work elsewhere.

Anyway, here it is:


:: Comments ::

moncler jacket moncler jackets # 72df905c4eda34cc7b5460cf57d5752b03ccf67e @ 01 Dec, 2011 02:35:31

Should a bazaar sports <a href="http://www.moncler4me.com/">moncler jacket</a> designed layer, the reporter sees many a line of sports brand clothing design into the avant-garde, gentle and elements, a change of the past spontaneously and effortlessly. One brand of long T-shirt, all is almost pure color design, and in this year's design, a lot of the broken beautiful element, more add green and lively; <a href="http://www.moncler4me.com/">Moncler Jackets</a>, in the pocket of the zipper ingenuity, adopted the sparkle of the metal elements as decoration, appear very avant-garde. Many brand sportswear, launched a joint body curve skirt outfit, appear woman flavour is dye-in-the-wood. In addition to the details, clothing in the design of collars, cuff place have some processing, swings get, lotus leaf sleeve, add sweet flavor. The reporter interviewed several random customers. The customer is a movement of miss wang brand loyal fans, she told the reporter, this year's these sports brand design she like very much, except in <a href="http://www.moncler4me.com/">moncler jackets</a> occasion wear besides, wear to work is no problem. And also think customer liu, fashionable element always let a person shine at the moment.

moncler 2012 # 72df905c4eda34cc7b5460cf57d5752b03ccf67e @ 01 Dec, 2011 02:36:37

<a href="http://www.cheapmoncler2012.com/">Moncler 2012</a> has spent heavily into brand promotion, not only invited Hong Kong red star Nicholas, superman combination of TWINS, small gas king pan wilber, and waiting for many star Jolin combination bear <a href="http://www.cheapmoncler2012.com/">moncler men</a> ambassador, more in the national scope chose CCTV, hunan TV, anhui, jiangsu TV variety and a number of famous media solution television ads, and in magazines, newspapers, network, car body, street signs such media on the plane advertising, and the large sports sponsorship of, all aspects of the brand communication. To support the development of the terminal, <a href="http://www.cheapmoncler2012.com/">moncler men</a> spent millions stores employ professional advisers to the company, for agents, distributors, a staff and internal market personnel system of professional training, from store location, decorate, recruit, interview, products purchasing, display, promote sales business, enterprise and brand shop comprehensive management and so on various provide guidance.
Comment on this story

Name, Nickname, or AKA :


Message :


Copyright Kia Kroas 2009