2 Replies Latest reply on Nov 21, 2004 12:43 PM by infectedrhythms

    Whats the point of notifications?

    infectedrhythms Novice

      Or how can I use notifications?

      Bassically I would like to track a specific occurance in my application say a thread count and when ever the thread count reaches a specific level send an e-mail. Or if a "batch" file failed to create send an e-mail.

      How do I track this in my application? Do I have to check the count every time I increase the thread count? And if the thread count is greater then a threshhold send a notification? Same for lets say FileCreationException or what you have...

      I find it overkill to have to create a Notification listener...

      And then finally in my app...

      long now = System.currentTimeMillis();
      MyNotifications notifications = new MyNotifications(this, getNextNotificationSequenceNumber(), now, "Thread count high");
      sendNotification(notifications);

      When I can just
      log.warn("Thread count high") and create and configure an smtp appender.

      Thanks

        • 1. Re: Whats the point of notifications?
          Dimitris Andreadis Master

          If you want to log messages and use an appender this is fine.

          Notifications lets you decouple the producer from potential consumers and do things that don't necessary involve logging/writing/sending a more or less unstructured string message.

          For example, when a module gets deployed (e.g. an .ear) a deployer will generate a notification and the jsr77 subsystem listens for that and creates a set of MBeans to "model" the deployed package.

          In addition, there are standard "monitor" mbeans that can be configured to poll attributes on other mbean and produce notifications, should certain thresholds get crossed. So this is really a way to add management function on an existing system, assuming you have the data already (e.g. an MBean with a ThreadCount attribute)


          • 2. Re: Whats the point of notifications?
            infectedrhythms Novice

            So I figure if I wanted to if my batch filed creation through an exception it would be simpler just to sebnd an e-mail with log4j?

            As for "threadcount" that wouldn't be an actuall attribute because it wouldn't have any set and get. On the other hand "maxthreadcount" would and only once "threadcount" reached the "maxthreadcount" then I would get the notification.

            Now how can I implement this?

            Would it be somewhere in my service's logic like...?

            start loop
            spawn thread
            increase threadcount

            if threadcount is > maxthreadcount
            send notification