-
Notifications
You must be signed in to change notification settings - Fork 2
Technical Details
The server is a full webapplication. The server will receive all messages send by the different clients. When logging into the server one can view his projects and all the messages send. The server will check if the clients send their regular 'i am alive' message and if there are any warnings or error messages send. When there is a problem the mTor server will send out alerts to the administrators of the project. The server is build in Struts, Hibernate and Spring it can be simply deployed in tomcat. By default it makes use of mysql database but with hibernate it could also use any other db supported by Hibernate.
The Client is started with the Spring 3.0 timer from the applicationContext-timer.xml. This file is called from the web.xml. In here the Process method of the Timer is called every 'cron time defined' time. When you want your app to send out status messages to mTor take the jar file and add it to your project:
<!-- adding mTor -->
<dependency>
<groupId>nl.bhit.mtor</groupId>
<artifactId>mTor</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- adding mTor -->
Open your web.xml and add the timer config file like this:
<!-- Context Configuration locations for Spring XML files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext-resources.xml
classpath:/applicationContext-timer.xml
classpath:/applicationContext-dao.xml
classpath:/applicationContext-service.xml
classpath*:/applicationContext.xml
/WEB-INF/applicationContext*.xml
/WEB-INF/cxf-servlet.xml
/WEB-INF/security.xml
</param-value>
</context-param>
Now status messages should be send.
##Message provider When you want to add your own message provider you can do simply by creating your own provider. Lets say you want to create a provider which will send out error messages to annoy the administrator.
You create a class as follows:
@MTorMessageProvider
public class AnnoyMTorMessageProvider {
@MTorMessage
public static SoapMessage getAnoyMessage() {
if(Math.random()<0.9)return null;
SoapMessage message = new SoapMessage();
message.setContent("Boo!");
message.setStatus(Status.ERROR);
return message;
}
}
This provider will send in 10% of the times an error message.
The sender should pickup all beans annotated with @MTorMessageProvider and will invoke the methods annotated with @MTorMessage. The returned message will be send of to the mTor server.
###Config Make sure this provdier is in a package which will be scanned. ##Properties
Add an mTor.properties file in your classpath (there is a default.mTor.properties which is used when it can not find the mTor.properties). This file should define the server url and the project id of this project.
#the full url pointing to the soap server and the service like: http://tomcat.bhit.nl/mTor/services/MessageService
mTor.server.url=http://localhost/mTor-1.0-SNAPSHOT/services/MessageService
#the project id is the id of the project where these messages belong to, like: 1
mTor.project.id=-1