herbetfy
asked on
how to passing variable in zend job queue?
Daer all,
i try use zend job queue, i have problem:
i have script A that do insert job that excute script B to job queue. and it run well. but when i try send varibles from script A to script B. how to access variable in script B that defined in script A?
i have try use setUserVars in script A.
i try use get_defined_vars. and i see my variable in $_server [JQ_USER_VARS_DATA] .
but how to access the varible i dont know.
i try use zend job queue, i have problem:
i have script A that do insert job that excute script B to job queue. and it run well. but when i try send varibles from script A to script B. how to access variable in script B that defined in script A?
i have try use setUserVars in script A.
i try use get_defined_vars. and i see my variable in $_server [JQ_USER_VARS_DATA] .
but how to access the varible i dont know.
script A
----------
$_REQUEST[msisdn] = 62817;
$_REQUEST[keyword] = "message";
$_REQUEST[oprId] = 1;
$_REQUEST[trxId] = 1;
$_REQUEST[Channel] = 3;
$_REQUEST[sdcId] = 2;
$executeFile = "scriptB.php";
$queue = new ZendApi_Queue(ZEND_PLATFORM_IP_PORT);
$queue->login(QUEUE_PASSWORD);
$checkoutJob = new ZendApi_Job($executeFile);
$checkoutJob -> setUserVariables(array('var'=>$_REQUEST));
$id = $queue->addJob($checkoutJob);
in Script B
var_dump(get_defined_vars());
output script B:
Array
(
[ZendEnablerConfig] => /usr/local/Zend/Platform/etc/fastcgi-jobq.conf
[PHP_FCGI_CHILDREN] => 1
[PHP_FCGI_MAX_REQUESTS] => 100
[PHPRC] => /usr/local/Zend/Platform/etc/fastcgi
[LD_LIBRARY_PATH] => /usr/local/Zend/Platform/lib
[FCGI_ROLE] => RESPONDER
[REQUEST_METHOD] => GET
[PATH_TRANSLATED] => /usr/local/Zend/Platform/JobQueue/M-ASP/cli/GetVar2.php
[JQ_USER_VARS_SIZE] => 264
[JQ_USER_VARS_DATA] => a%3A1%3A%7Bs%3A3%3A%22var%22%3Ba%3A6%3A%7Bs%3A6%3A%22msisdn%22%3Bd%3A62817%3Bs%3A7%3A%22keyword%22%3Bs%3A10%3A%22message%22%3Bs%3A5%3A%22oprId%22%3Bi%3A1%3Bs%3A5%3A%22trxId%22%3Bi%3A1%3Bs%3A7%3A%22Channel%22%3Bi%3A3%3Bs%3A5%3A%22sdcId%22%3Bi%3A2%3B%7D%7D
[JQ_GLOBALS_SIZE] => 76
[JQ_GLOBALS_DATA] => a%3A1%3A%7Bs%3A5%3A%22_POST%22%3Bs%3A14%3A%22a%253A0%253A%257B%257D%22%3B%7D
[REQUEST_URI] => /usr/local/Zend/Platform/JobQueue/M-ASP/cli/GetVar2.php
[SCRIPT_FILENAME] => /usr/local/Zend/Platform/JobQueue/M-ASP/cli/GetVar2.php
[PHP_SELF] =>
[REQUEST_TIME] => 1240923545
[argv] => Array
(
)
[argc] => 0
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In both files add the line (near/at the top) ...
session_start();
Now you can use the $_SESSION super global.
If you ...
$_SESSION['Name'] = 'Richard';
in script A, you can ...
echo $_SESSION['Name'];
in script B.
More details can be read at http://docs.php.net/manual/en/book.session.php