... h2. Event Notifications in Messaging Server Overview
Sun Messaging Server 6.3 and later provides two mechanisms for event notifications. One mechanism is the ENS event notification plugin. The second is the new JMQ (Java Message Queue) event notification plugin.
The following is a quick-start guide on getting JMQ notifications working along with a sample program to show the output. These steps were tested on a Single-Host Solaris 10u3 x86 installation. For details about that installation, see [Deployment Example: Sun Java Communications Suite 6 on a Single Host|CommSuite6:Sun Java Communications Suite 6 on a Single Host].
h2. Enable Java Message Queue (JMQ)
*Modify the JMQ configuration file {{/etc/imq/imqbrokerd.conf}}.*
{noformat} replace:
AUTOSTART=NO
with:
AUTOSTART=YES {noformat}
*Start Java Message Queue.*
{noformat} /etc/init.d/imq start {noformat}
*Reset {{admin/guest}} password & add {{jesuser}} account.*
{noformat} cd /usr/bin ./imqusermgr update -u admin -p password Are you sure you want to update user admin? (y/n) y ./imqusermgr update -u guest -p guest Are you sure you want to update user guest? (y/n) y ./imqusermgr add -u jesuser -g user -p password User repository for broker instance: imqbroker User jesuser successfully added. {noformat}
h2. Configure and Enable the Messaging Server jmqnotify Plugin
*Enable the appropriate messaging server settings.*
{noformat} cd /opt/SUNWmsgsr/sbin ./configutil -o local.store.notifyplugin.jmqnotify.NewMsg.enable -v 1 ./configutil -o local.store.notifyplugin.jmqnotify.UpdateMsg.enable -v 1 ./configutil -o local.store.notifyplugin.jmqnotify.DeleteMsg.enable -v 1 ./configutil -o local.store.notifyplugin.jmqnotify.maxHeaderSize -v 1024 ./configutil -o local.store.notifyplugin.jmqnotify.jmqHost -v "127.0.0.1" ./configutil -o local.store.notifyplugin.jmqnotify.jmqPort -v "7676" ./configutil -o local.store.notifyplugin.jmqnotify.jmqUser -v "jesuser" ./configutil -o local.store.notifyplugin.jmqnotify.jmqPwd -v "password" ./configutil -o local.store.notifyplugin.jmqnotify.DestinationType -v "queue" ./configutil -o local.store.notifyplugin.jmqnotify.jmqQueue -v "jesms" ./configutil -o local.store.notifyplugin.jmqnotify.Priority -v 3 ./configutil -o local.store.notifyplugin.jmqnotify.ttl -v 1000 ./configutil -o local.store.notifyplugin.jmqnotify.Persistent -v 1 {noformat}
For Messaging Server 6.3 set the following:
{noformat} ./configutil -o local.store.notifyplugin -v '/opt/SUNWmsgsr/lib/libjmqnotify$jmqnotify' {noformat}
For Messaging Server 7.0 and later, set the following:
{noformat} ./configutil -o local.store.notifyplugin -v '/opt/sun/comms/messaging/lib/libjmqnotify$jmqnotify' {noformat}
*Restart Messaging Server.*
{noformat} ./stop-msg ./start-msg {noformat}
*Verify that the {{jmqplugin}} is working.*
{noformat} [25/Jul/2007:14:27:31 +1000] myhost imapd[18605]: General Notice: jmqNotify Loading plug-in $Id: jmqnotify.c,v 1.11.2.2 2006/03/03 23:25:07 pcoates Exp $: jmqnotify Jul 12 2007 20:05:44 [25/Jul/2007:14:27:31 +1000] myhost imapd[18605]: General Notice: jmqNotify readParams debugLevel=0 maxBodySize=0 maxHeaderSize=1028 hasNewMsg=1 hasUpdateMsg=1 hasReadMsg=1 hasDeleteMsg=1 hasPurgeMsg=1 jmqHost=127.0.0.1 jmqPort=7676 jmqQueue=jesms jmqUser=jesuser jmqPwd=password destinationtype=Queue Priority=3 ttl=1000 Persistent = 1 {noformat}
h2. Test the JMQ Mechanism By Using the jmqclient
*Run the supplied jmqclient software.*
The original source code ({{jmqclient.c}}) is available in the same directory as the binary and can provide you with a basis for your own Messaging event handling software.
{noformat} cd /opt/SUNWmsgsr/examples/jmqsdk/ chmod u+x jmqclient export LD_LIBRARY_PATH=/opt/SUNWmsgsr/lib/ ./jmqclient -u jesuser -w password -q jesms {noformat}
Send a test email with the above software running, you should see output similar to the following:
{noformat} message is persistent Event type=NewMsg timestamp=Wed Jul 25 14:30:40 2007 hostname=myhost process=tcp_lmtp_server pid=18618 mailboxName=testuser uidValidity=1177041110 imapUID=120 size=931 hdrLen=920 numMsgs=69 numSeen=0 numDeleted=62 numSeenDeleted=5 Received message: Received: from conversion_peruser-daemon.myhost.sun.com by myhost.sun.com (Sun Java(tm) System Messaging Server 6.3-3.01 (built Jul 12 2007; 32bit)) id <0JLP00E00WJ4DC00@myhost.sun.com> for test.user@sun.com; Wed, 25 Jul 2007 14:30:40 +1000 (EST) ... {noformat}
h2. Verify the JMQ Broker
You can verify that the JMQ software is operational at any time by running the following command:
{noformat} cd /usr/bin ./imqcmd query bkr -u admin Password: password {noformat}
h2. Related Information
Use the following links to find more information about producing a Java program to listen and process Messaging Server events (rather then the C based {{jmqclient}} reference program used previously):
* [Java Message Service Tutorial|http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/jms_tutorialTOC.html]
* [Java Message Server Programming Interface|http://java.sun.com/products/jms/javadoc-102a/javax/jms/package-summary.html]
* [Java Message Queue Developer's Guide for Java Clients|http://docs.sun.com/app/docs/doc/819-4469] |