Laravel 4.2 Queue Push Syncing When Set To Redis - laravel

Using Laravel 4.2 framework. Was on 4.1.x but switching back to that version, has the queue::push still firing immediately as if the queue config was set to sync but this is set to redis.
When running the queue closure, it fires the command immediately. Testing with sample output in the actual command to confirm. I can connect to the redis db without an issue with the configuration set in the config file.
Here is the syntax of my queue closure:
Queue::push(function($job) use ($placeId)
{
Artisan::call('testcommandname', [$placeId]);
$job->delete();
});
Not sure if I am overlooking something or what? Thanks for the help.

So thinking this was an error due to a framework upgrade, it ended up being that I wasn't setting the correct environment configuration for queues.

Related

Laravel Horizon: A job is always paused

On the Laravel Horizon dashboard, some job always shows as "paused":
How can I prevent this issue?
I had the same issue. It seemed to work and suddenly jobs would pause for no reason. I was using two applications with the same redis server, so conflicts would occur occasionally.
To resolve this you need to modify config/database.php and change the value of the key redis.default.database so the two (or more) applications don't mix up their keys.

Notifications not added to queue

I've provisioned a Laravel Forge server and configured it to use redis for queues via .env:
QUEUE_DRIVER=redis
My settings for Redis in both config/queue.php and config/database.php are the defaults found in a new laravel project.
The problem is that when a mail notification is triggered, it is never added to the queue. It never gets to the processing stage.
I've tried using forge's queue interface as well as SSH into the server and running a simple
php artisan queue:listen
without any parameters. In both cases, no results (using the artisan command confirms no job is added to the queue).
Interestingly, I tried Beanstalkd:
QUEUE_DRIVER=beanstalkd
and suffered the same problem.
As a sanity check, I set the queue driver to sync:
QUEUE_DRIVER=sync
and the notification was delivered without issue, so there isn't a problem with my code in the notification class, it's somewhere between calling the notify method and being added to the queue.
The same configuration running locally works fine. I can use
php artisan queue:listen
and the notifications go through.
After an insane amount of time trying to address this, I discovered it was because the app was in maintenance mode. To be fair, the documentation does state that queued jobs aren't fired in maintenance mode, but unless you knew maintenance mode was the culprit you probably wouldn't be looking in that section.

Using redis with heroku

This is my first time using redis and the only reason I am is because I'm trying out autocomplete search tutorial. The tutorial works perfectly in development but I'm having trouble setting up redis for heroku.
I already followed these steps on the heroku docs for setting up redis but when I run heroku run rake db:seed I get Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
I'm not very familiar with heroku so if you guys need any more information let me know.
Edit
I've completed the initializer steps shown here and when I run heroku config:get REDISCLOUD_URL the result is exactly the same as the Redis Cloud URL under the config vars section of my Heroku settings.
Following the documentation, I then set up config/initializers/redis.rb like so:
if ENV["REDISCLOUD_URL"]
$redis = Redis.new(:url => ENV["REDISCLOUD_URL"])
end
Just to check, I tried substituting the actual URL for redis cloud inside the if block instead of just the REDISCLOUD_URL variable but that didn't work. My error message hasn't changed when I try to seed the heroku db.
It’s not enough to just create a $redis variable that points to the installed Redis server, you also need to tell Soulmate about it, otherwise it will default to localhost.
From the Soulmate README you should be able to do something like this in an initializer (instead of your current redis.rb initializer, which you won’t need unless you are using Redis somewhere else in your app):
if ENV["REDISCLOUD_URL"]
Soulmate.redis = ENV["REDISCLOUD_URL"]
end
Looking at the Soulmate source, an easier way may be to set the REDIS_URL environment variable to the Redis url, either instead of or as well as REDISCLOUD_URL, as it looks like Soulmate checks this before falling back to localhost.
Your code is trying to connect to a local Redis instance, instead the one from Redis Cloud - make sure you've completed the initializer step as detailed in order to resolve this.

How to change Infinispan cache settings after it is created?

In my application i'm using Infinispan 5.3 version and I want to change setting after cache is initialized. Default settings will be loaded from xml file and some of the settings ( ex : eviction maxEntries, lifespan, etc ) should be able to change any time of application running (This is changed by sysadmin). Is there way to changed settings of already created cache ?
I tried EmbeddedCacheManager.defineConfiguration(String cacheName, Configuration configurationOverride); but this has no effect on already created cache.
Please, take into account that in the Infinispan version 5.3 there is no possibility to change cache configuration "on the fly". You need to restart your service with new configuration in case of any wanted change.
This is something the community might want to work on in the future. However, such a task is not easy because you need to figure out how to correctly deal with affected data immediately after the configuration change.
Feel free to raise new feature request: https://issues.jboss.org/browse/ISPN/

How to clear Laravel Queue using iron.io

I'm working on TeamSpeak management system based on Laravel 4
the problem is when i restart the script it add the queue again unless i restart the Queue listener
is there a way to clear the old Queue on script startup without the need to restart the queue:listen ??
am using Iron.io service as a queue engine
Thanks in advance
//EDIT
Thanks to "thousandsofthem"
it works with Laravel like this:
$queue_name = Config::get('queue.connections.iron.queue');
Queue::getIron()->clearQueue($queue_name);
How about touching $iron_mq->clearQueue($queue_name) ?
https://github.com/iron-io/iron_mq_php/blob/master/IronMQ.class.php#L235
No idea how Laravel exposes it though

Resources