in reply to POCO::EasyDBI reconnect

Hello,
PoCo::EasyDBI author here.

Apocalypse is correct.
Set max_retries => -1 and no_connect_failures => 1 and it will reconnect forever and it won't bother you with failures.

If you care about the connect errors then set connect_error with a array of session alias/id and event, or a code ref

Replies are listed 'Best First'.
Re^2: PoCo::EasyDBI reconnect
by avo (Pilgrim) on Jan 25, 2009 at 09:24 UTC
    Hi Xantos, I've made the two options available upon EasyDBI->spawn
    POE::Component::EasyDBI->spawn( alias => 'EasyDBI', dsn => "DBI:mysql:database=$mysql_database;host=$mysql +_host;port=3306", username => "$mysql_username", password => "$mysql_password", options => { max_retries => -1, no_connect_failures => 1, }, );
    But However, when I do this:
    POE::Session->create( inline_states => { _start => sub { print "DEBUG: SQL QUERY START\n"; $_[KERNEL]->post( 'EasyDBI', insert => { sql => "INSERT INTO camincoming (site_id,c +am_id,eventtime,filestamp,filename) VALUES (?,?,current_timestamp,?,? +);", placeholders => [ $input->{site}, $input-> +{dir}, $mysqldate, $input->{filename} ], event => 'result_handler', } ); }, result_handler => sub { print Dumper($_[ARG0]); } } );
    Then I start my script which works fine. After I break the connection to MySQL by stopping the mysql. I get the following through result_handler
    $VAR1 = { 'sql' => 'INSERT INTO camincoming (site_id,cam_id,eventtime, +filestamp, filename) VALUES (?,?,current_timestamp,?,?);', 'session' => 5, 'error' => 'POE::Component::EasyDBI was shut down forcibly!' +, 'action' => 'insert', 'id' => 0, 'event' => 'result_handler', 'placeholders' => [ '24', '1', '2009-01-20 18:14:40', 'videotrg20090120181644_0.jpg' ] };

    after this ... if I start back MySQL ... further nothing happens. I think because the spawned EasyDBI is no longer there. Can you please advice, what I am doing wrong. Thank you very much for your support.