Monitoring Notification Server

| | Comments (0) | TrackBacks (0)

You know those pesky collaboration notifications you're always trying to keep track of? Who's to know if they're really getting sent off to the people you think they are? Unfortunately, the notification logs themselves aren't much help, since they only log errors, not successes. What that means is you have to wait for the notification queue to fill on Collaboration server or an error to occur if you want to see something go wrong.

But what if we could send out our own notifications without using the UI, so they could be controlled and monitored via a script? What indeed...

import com.plumtree.collaboration.messaging.notification.messages.NotificationUtil;
import java.util.ArrayList;

public class TestNotifications {
    public static void main(String args[]) {
        
        if (args.length <= 0) {
            System.out.println("usage: TestNotifications {userIds..}");
            return;
        }
        
        System.out.println("Initializing notification utility...");
        NotificationUtil nUtil = NotificationUtil.getInstance();
    
        // parse each argument as a user id and add it to the recipients list
        System.out.println("Creating new recipient list...");
        ArrayList emails = new ArrayList();
        for (int i = 0; i < args.length; i++) {
            try {
                Integer ix = new Integer(args[i]);
                emails.add(ix);
                System.out.println("Added userid: " + args[i]);
            } catch (Exception ex) {
                System.out.println("Could not parse userid: " + args[i]);
            }
        }
        
        System.out.println("Sending error notification email...");
        nUtil.sendEmailErrorNotification("This is a test notification.", emails);
        System.out.println("Mail send completed.");
        
        try {
            Thread.sleep(10000); // sleep long enough to send the message (10s)
        } catch (InterruptedException iex) {
        } finally {
            // we need to kill all threads, since notification is event driven
            System.exit(0);
        }
    }
}

The code above will allow you to send notifications (it's written in Java) via a command line. You simply need to include the jar's in $PT_HOME/ptnotification/4.x/lib/java in your classpath (probably not all of them, but I haven't bothered to figure out which ones). The notification itself will be an error message with the text "This is a test notification." in the body.

Here is the script I used to launch it (DOS users will need to do some conversion).

Here is the jar file with source.

You can set up a simple notification monitor by creating a new user in the portal and changing the email address property to the email account or distribution list of your choice. Next, record the user ID and pass it on the command line to this utility. Have fun!

(generic disclaimer: I make no guarantees this code will work, properly, etc, etc)

0 TrackBacks

Listed below are links to blogs that reference this entry: Monitoring Notification Server.

TrackBack URL for this entry: http://hross.net/mt/mt-tb.cgi/15

Leave a comment

About this Entry

This page contains a single entry by hross published on September 16, 2007 2:12 PM.

What's in a Card? was the previous entry in this blog.

Collaboration Clustering Explained is the next entry in this blog.

Blogroll


Integryst

Function1

Fabien Sanglier

Bill Benac

Jordan Rose

Chris Bucchere

Robert Herrera

Nanek Blog Aggregator

Spartan Java




if you'd like to be listed here.




I don't blog about non-tech issues here, but you can check my Google Reader Shared Items if you want to know what I'm currently interested in.

Categories