|
The default implementation for one-way communication is HTTP communication. In a distributed setup, the DMS transfers the network data to the central server as XML packets over HTTP protocol. You can also plug-in XML over HTTPS, or SOAP over HTTP. Default implementations for these are also provided.
Default Implementation for HTTP
The default implementation for HTTP communication is available in the Distributed Mediation Server and the Central Server at the following locations respectively, <DMS HOME>/default_impl/http_impl and <Central Home>/default_impl/http_impl directories. The implementations at the Distributed Mediation Server are HTTPProbeCommInit and SPPHttpRequest and at the Central Server, the RegionalListener servlet is present.
The HTTPProbeCommInit implementation is
present in the Distributed Mediation Server and establishes the connection
with the Central Server. This class implements the SPPCommInitIfc
and the open() method is used to establish the
connection. If the establishing the connection is not successful, a CommunicationException
is displayed.
|
... URL urlObj = new URL("http://"+serverAddress+":"+serverPort+servlet); connection = (HttpURLConnection)urlObj.openConnection(); connection.getInputStream(); ... ... |
The SPPHttpRequest session class initialized
by HTTPProbeCommInit is an implementation
of SPPRegionalCommIfc
. Once the communication is established, the HTTPProbeCommInit
returns this session instance as shown below :
|
... SPPHttpRequest commImpl = new SPPHttpRequest(serverAddress, serverPort); return commImpl; ... |
The initialize() method of SPPHttpRequest constructs the request URL and returns true. The read() method gets the data through the HTTP GET request. The write() method writes the data to the Central Server by posting the data, through the HTTP servlet.
|
... connection = openConnection(reqURL); if(connection == null) { return null; } connection.setRequestMethod("GET"); InputStream res = connection.getInputStream();
if(res.available() > 0) { ois = new ObjectInputStream(res); Object object = ois.readObject(); dataObject = (DataObject)object; } ... |
|
... connection = openConnection(url); if(connection == null) { return null; } connection.setRequestMethod("POST"); ObjectOutputStream oos = new ObjectOutputStream(connection.getOutputStream()); oos.writeObject(dataObject); ... |
The RegionalListener servlet is used for reading and writing data to the Central Server using the doGet() and doPost() methods respectively.
|
public void doPost(HttpServletRequest servReq,HttpServletResponse servResp) throws ServletException,IOException { .... DataObject dataObj = commApi.transferDataToNOC(dataObject, regionID); .... } public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException, ServletException) { ... dataObject = commApi.transferDataToReg(regionID); ... } |
You can refer to the default implementation available in <Central Home>/default_impl/dms/http_impl/fe/RegionalListener.java.
Sample Entries in CommunicationInfo.xml
In Central
|
... <Communication> <MainProps Mode="1" InitImpl="" MaxBufferSize="25" WriteInterval="" ReadInterval="" /> </Communication> ... |
In Distributed Mediation Server
|
... <Communication> <MainProps Mode="1" InitImpl="com.adventnet.nms.extranet.remote.communication.http.probe.HTTPProbeCommInit" MaxBufferSize="25" WriteInterval="300" ReadInterval="5" /> - <UserProps> <Property Name="Servlet" Value="/servlet/com.adventnet.nms.extranet.remote.communication.fw.fe.RegionalListener" /> </UserProps> </Communication> ... |
|