<DeliveranceMail Communications


Home
Download
Installation Docs
API Docs
Taglibs
Acknowledgements
Mailinglist

DeliveranceMail

Communication with Deliverance


There are three main ways to communicate with a deliverance server.

  1. In process
  2. Native Sockets
  3. RMI (Remote Method Invocation)

In Process

This method requires that the code accessing the server is running in the same JVM as the server. To start a Deliverance server call the following code in your application
com.tp23.deliverance.server.DeliveranceServer server = new DeliveranceServer();
// optionally start with a different config file
server.setConfigFile("server.xml");
server.init();
// call start to start the cron scheduler
server.start(); 
All the methods of DeliveranceServer can then be called by your application. No configuration is required for this method.

Native Sockets

This method of communication opens up a port on the server which defaults to 2323. Simple text commands can be sent down this socket to control the server. This is not as flexible as In Process but can fire triggers and start and stop the scheduler and kill the server process when required. There is a GUI console to access the server via native sockets. If you use the server to send out preconfigured messages this method is fine and will enable you to write other non Java clients that can communicate with the server.
See com.tp23.deliverance.server.control.ServerControl for the list of commands to send the to server.
Configuration
I in the server.xml file, (or the file you use to configure the server if you change it when you start the server)
set the element to set the port value to the port you wish to use to communicate
N.B. there is no authentication on this port so if you open it up on the firewall anyone with the correct knowledge and tools can shut down your server.

RMI (Remote Method Invocation)

This method of communication allows you to talk to the server and pass Java object in the method calls. This is useful from within a Java application. The server requires two ports on for the RMI registry and one for the communication with the server. All the methods of com.tp23.deliverance.server.control.RMIManagerInterface can be used to control the server.
This method of communication allows Properties to be send when the triggers are fired, as long as the data is Serializable.
Configuration
I in the server.xml file, (or the file you use to configure the server if you change it when you start the server)
set the <server-manager-class> element to
<server-manager-class class="com.tp23.deliverance.server.control.RMIManager">
  <control-host value="localhost"/>
  <control-port value="2323"/>
  <registry-port value="1099"/>
</server-manager-class>
N.B. there is no authentication on the ports so if you open it up on your firewall anyone with the correct knowledge and tools can shut down your server.

Usage
To access the server your code first has to lookup the remote server using JNDI, then it will be able to create a stub to talk to the server with.
Registry r = LocateRegistry.getRegistry("localhost", "1099");
manager = (RMIManagerInterface)r.lookup("//localhost/deliverance");
You can then fire triggers
Map parametersMap = new HashMap();
//... add parameters to the map
parametersMap.put("name","value");
manager.fireTrigger("theTriggerName",parametersMap);

The parameters are accessible in the destination object in the JSP.

String value = destination.getParameter("name");

{logo}