3 Replies Latest reply on Jun 4, 2009 7:05 AM by shrimad

    How to schedule messages?

    shrimad

      I wish to configure scheduler or timer to automatically post messages to some topic every n seconds.

      How can I do that?

      Thanks.

        • 1. Re: How to schedule messages?
          gaohoward

          I think you can do it in your application. JBM 1.4 doesn't provide such utility.

          • 2. Re: How to schedule messages?
            shrimad

             

            "gaohoward" wrote:
            JBM 1.4 doesn't provide such utility.

            Ah, ok ((

            • 3. Re: How to schedule messages?
              shrimad

              Hooray!!! Made it! ))

              <?xml version="1.0" encoding="UTF-8"?>
              <server>
               <mbean code="javax.management.timer.Timer" name="jboss.monitor:name=HereTheName,type=Timer"/>
              
               <mbean code="org.jboss.monitor.services.TimerService"
               name="jboss.monitor:name=HereTheName,type=TimerService">
               <attribute name="NotificationType">jboss.monitor.herethename</attribute>
               <attribute name="NotificationMessage">ping!</attribute>
               <attribute name="TimerPeriod">10sec</attribute>
               <depends optional-attribute-name="TimerMBean">
               jboss.monitor:name=HereTheName,type=Timer
               </depends>
               </mbean>
              
               <mbean code="org.jboss.monitor.services.ScriptingListener"
               name="jboss.monitor:service=ScriptingListener">
               <attribute name="SubscriptionList">
               <subscription-list>
               <mbean name="jboss.monitor:name=HereTheName,type=Timer"/>
               </subscription-list>
               </attribute>
              
               <attribute name="ScriptLanguage">beanshell</attribute>
               <attribute name="Script">
               <![CDATA[
               import javax.naming.InitialContext;
               import javax.jms.*;
              
               InitialContext ctx = new InitialContext();
               TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("ConnectionFactory");
               TopicConnection conn = tcf.createTopicConnection();
               TopicSession session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
               conn.start();
              
               Topic topic = (Topic)ctx.lookup("topic/HeretheTopicName");
               TopicPublisher send = session.createPublisher(topic);
               Message m = session.createMessage();
               send.publish(m);
               send.close();
               conn.close();
               ]]>
               </attribute>
               </mbean>
              
              </server>