[rabbitmq-discuss] MYSQL not getting disconnected Consumer

reddylast reddylast at gmail.com
Mon Mar 25 13:15:02 GMT 2013


Hi Tim,

Thanks for you reply.

I posted this issues also on MySQL support forums and Stack Overflow, but,
didn’t get any solution. Please see the samle code of consumer script which
have right now, hope this will help you to get an idea on this issue :

$connection = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$channel = $connection->channel();
$channel->queue_declare($queue, false, true, false, false);
$channel->exchange_declare('myexchange', 'direct', true, true, false);
$channel->queue_bind('myqueue', $exchange, $queue);
$callback = function($msg, $db) { 

	$data = json_decode($msg->body, true); // on producer script I've send data
in json format
	$db->mysqlConnect();
	$db->mysqlQuery("update jobstable set status='in-progress' where
id=".$data['id']);
	$db->mysqlDisconnect();

	processData($data); // this will process data

	$db->mysqlConnect();
	$db->mysqlQuery("update jobstable set status='complete' where
id=".$data['id']);
	$db->mysqlDisconnect();

};

while (count($channel->callbacks)) {
	$channel->wait();
}

$channel->close();
$connection->close();

Thanks,
Reddy


function processData(){
	/* I'm also running some mysql queries. */
}










 



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/MYSQL-not-getting-disconnected-at-consumer-side-tp25619p25690.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list