Package com.drighetto.essai.springactivemq

Source Code of com.drighetto.essai.springactivemq.SampleUsingQueue

package com.drighetto.essai.springactivemq;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.drighetto.essai.springactivemq.processor.MyMessageProducer;

/**
* Example using QUEUE
*
* @author Dominique RIGHETTO<br>
*         29 nov. 07<br>
*/
public class SampleUsingQueue {

  /**
   * Entry point
   *
   * @author Dominique RIGHETTO<br>
   *         29 nov. 07<br>
   * @param args
   *            Command line
   */
  @SuppressWarnings("boxing")
  public static void main(String[] args) {
    try {
      // Create spring context
      ApplicationContext appCtx = new ClassPathXmlApplicationContext(
          "applicationContext-Queue.xml");

      // Get JMS template for message sending
      MyMessageProducer myMessageProducer = (MyMessageProducer) appCtx
          .getBean("myMessageProducer");

      long i = 0;
      while (true) {
        myMessageProducer.sendMessage();
        System.out
            .printf(
                "Msg Count :%s - FreeMemory : %s - MaxMemory : %s - TotalMemory : %s\n",
                i, Runtime.getRuntime().freeMemory(), Runtime
                    .getRuntime().maxMemory(), Runtime
                    .getRuntime().totalMemory());
        i++;
        Thread.sleep(20);
      }

      // Wait for let consumers work....
      // Thread.sleep(100000);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(2);
    }

  }

}
TOP

Related Classes of com.drighetto.essai.springactivemq.SampleUsingQueue

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.