A simple Java library designed to help you monitoring your routines with www.cronitor.io
Java
Latest commit f16558a Aug 4, 2016 @nnerny nnerny committed on GitHub Merge pull request #2 from sm360/fix_empty_monitor_code_And_Add_Timeo…
…ut_cronitor_call

Add timeout and Don't call cronitor if we pass empty or null monitor code
Permalink
Failed to load latest commit information.
src Changed exception variable Aug 4, 2016
.gitignore Clean .gitignore Jun 7, 2016
README.md Added manual tests Aug 4, 2016
pom.xml Add 10 second time to cronitor call. Aug 2, 2016

README.md

cronitor-client

What is it ?

Cronitor-client is a simple Java library designed to help monitor your app. With the help of www.cronitor.io, you can easily monitor the routines of your Java projects.

How to install it on your Maven project ?

Simply add this line in your pom.xml file :

<dependency>
    <groupId>ca.sm360.cronitor</groupId>
    <artifactId>cronitor-client</artifactId>
    <version>1.0.1</version>
</dependency>

Usage with Spring

Declare a new bean in your Spring configuration :

// if you are using the Auth Key of your Cronitor account
<bean id="cronitorClient" class="ca.sm360.cronitor.client.CronitorClient">
     <constructor-arg index="0" value="authKey"/>
</bean>

// otherwise
<bean id="cronitorClient" class="ca.sm360.cronitor.client.CronitorClient" />

Then simply inject this bean into the class containing the routine to monitor :

@Resource
private CronitorClient cronitorClient;

Usage without Spring

Simply declare a new CronitorClient instance in the class containing the routine to monitor :

CronitorClient cronitorClient = new CronitorClient();

Examples

ping /run on a monitor

    try {
        // ping the /run URL on your monitor
        cronitorClient.run(monitorCode);
    } catch (Exception e) {
        // handle the raised exception the way you want
    }

ping /complete on a monitor

    try {
        // ping the /complete URL on your monitor
        cronitorClient.complete(monitorCode);
    } catch (Exception e) {
        // handle the raised exception the way you want
    }

ping /fail on a monitor

    try {
        // ping the /fail URL on your monitor with no extra message
        cronitorClient.fail(monitorCode);

        // ping the /fail URL on your monitor with an extra message
        cronitorClient.fail(monitorCode, message);
    } catch (Exception e) {
        // handle the raised exception the way you want
    }

pause a monitor

    try {
        // pause a monitor for a number of hours
        cronitorClient.pause(monitorCode, numberOfHours);
    } catch (Exception e) {
        // handle the raised exception the way you want
    }

unpause a monitor

    try {
        // unpause a monitor
        cronitorClient.unpause(monitorCode);
    } catch (Exception e) {
        // handle the raised exception the way you want
    }

How to contact us ?

If you want to share an idea, report an issue or just say hello, do not hesitate to write to us at github@360.agency

Have a great day!