![]() | ![]() | ![]() |
| |||||||||||||||
![]() | ||||||||||||||||||
![]() | ![]() | |||||||||||||||||
Resin 3.1 Documentation Examples Changes Quercus Database Amber EJB SOA/ESB IoC JMS Servlet JMX Hessian Security JMS/PHP Send JMS/PHP Receive JMS Listener JMS IOC Listener |
Files in this tutorial
Using JMS in QuercusQuercus offers a simplified messaging interface built upon JMS. This functionality makes it possible to send and receive messages using either the Resin JMS implementation or any other messaging service with a JMS implementation. Many features of JMS are designed for message-driven services which make sense in the Java world, but are not appropriate for PHP. This tutorial focuses on sending messages. Sending JMS messages from a PHP scriptIn this example, the script checks a POST variable "message" and if it is set, sends the value of that variable to a JMS queue. A Message Driven Bean (MDB) receives these messages and records them. The record is displayed by a servlet. if (array_key_exists("message", $_POST)) { $queue = new JMSQueue("jms/Queue"); if (! $queue) { echo "Unable to get message queue!\n"; } else { if ($queue->send($_POST["message"]) == TRUE) { echo "Successfully sent message '" . $_POST["message"] . "'"; } else { echo "Unable to send message '" . $_POST["message"] . "'"; } } }
The programming model of the Quercus JMS interface is first to create
a connection to a queue by instantiating a Configuring JMS for PHP and Java
JMS requires that two resources be set up: A
<resource jndi-name="jms/ConnectionFactory" type='com.caucho.jms.ConnectionFactoryImpl' />
The example above uses the queue <resource jndi-name="jms/Queue" type='com.caucho.jms.memory.MemoryQueue' /> The complete configuration is in WEB-INF/resin-web.xml.
|