Configuring a Stand-alone consumer

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
m (Protected "Configuring a Stand-alone consumer" [edit=sysop:move=sysop])
 
Line 1: Line 1:
[http://sematild.qsh.eu/resource1375.htm ji young baek video] [http://releltl.0lx.net/20081111-lizzie-migure-movie.html lizzie migure movie soundtrack] [http://vihencbr.0lx.net/istanbul-not.html istanbul not constantinople music video] [http://zelgetgo.0lx.net/new153.htm asian videographers wedding] [http://zelzelqa.is-the-boss.com/news-pedal-to-the-2009-01-04.html pedal to the metal no cd]
+
 
[http://relquaca.is-the-boss.com/20090101-norton-antivirus.html norton antivirus 2004 serials] [http://licawol.strefa.pl/resource890.htm kari movie wuhrer] [http://dronoubr.0lx.net/illinois-joppa.html illinois joppa movie theater] [http://relquaca.is-the-boss.com/sitemap.html http] [http://bukgetert.0lx.net/article-1996.htm joblo.com present the 50 coolest movie of all time]
+
[http://chifire.strefa.pl/news-1811.html anal gallery movie teen] [http://zelgetgo.0lx.net/new1132.htm masala movies] [http://saererg.0lx.net/20081109-portable-dvd.htm portable dvd movie player] [http://sedplxca.is-the-boss.com/leisure-suit-larry-2008-12-28.htm leisure suit larry trial expired crack] [http://zelgetgo.0lx.net/new1800.htm photograph video code]
+
[http://tarobasal.strefa.pl/article1256.htm live action movie dbz] [http://tulilre.strefa.pl/2009-01-01-love-is-a-many-splendid.html love is a many splendid thing movie] [http://fademon.0lx.net/article-5.htm night of the demon the movie] [http://vihencbr.0lx.net/recording-tape.html recording tape video] [http://relquaca.is-the-boss.com/20081228-occupational-license.html occupational license search lee county florida]
+
 
monelo
 
monelo
 
Note: this does not work yet, any help would be greatly appreciated! My goal is to have a nice php form submit jobs to a queue and have a standalone java application respond.
 
Note: this does not work yet, any help would be greatly appreciated! My goal is to have a nice php form submit jobs to a queue and have a standalone java application respond.

Latest revision as of 17:22, 9 January 2009

monelo Note: this does not work yet, any help would be greatly appreciated! My goal is to have a nice php form submit jobs to a queue and have a standalone java application respond.


when i run this app, here is the output:

  1. >java SimpleConsumer jms/Queue

Destination name is jms/Queue Progress JNDI API lookup failed: java.lang.NullPointerException

So that tells me it makes it to the lookup of the jms/ConnectionFactory item.

SimpleConsumer.java:



import javax.jms.*; import javax.naming.*; import java.util.Hashtable;


public class SimpleConsumer {

   public static void main(String[] args) {
       String destName = null;
       Context jndiContext = null;
       ConnectionFactory connectionFactory = null;
       Connection connection = null;
       Session session = null;
       Destination dest = null;
       MessageConsumer consumer = null;
       TextMessage message = null;
       if (args.length != 1) {
           System.out.println("java SimpleConsumer: dest_name");
           System.exit(1);
       }
       destName = new String(args[0]);
       System.out.println("Destination name is " + destName);

// Properties env = new Properties( );

       Hashtable env = new Hashtable();
       //env.put(Context.INITIAL_CONTEXT_FACTORY, "com.caucho.jms.ConnectionFactoryImpl");
       env.put(Context.INITIAL_CONTEXT_FACTORY, "com.caucho.naming.InitialContextFactoryImpl");
       env.put(Context.URL_PKG_PREFIXES, "com.caucho.naming");
       // ... specify the JNDI properties specific to the vendor


       try {
               InitialContext jndi = new InitialContext(env);
           //jndiContext = new InitialContext(env);
       } catch (NamingException e) {
           System.out.println("Could not create JNDI API context: " +
               e.toString());
           System.exit(1);
       }
       System.out.println("Progress");
       try {
           connectionFactory = (ConnectionFactory) jndiContext.lookup(
                   "jms/ConnectionFactory");
       System.out.println("more Progress");
           dest = (Destination) jndiContext.lookup(destName);
       } catch (Exception e) {
           System.out.println("JNDI API lookup failed: " + e.toString());
           System.exit(1);
       }
       try {
    connection = connectionFactory.createConnection();
           session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
           consumer = session.createConsumer(dest);
           connection.start();
           while (true) {
               Message m = consumer.receive(1);
               if (m != null) {
                   if (m instanceof TextMessage) {
                       message = (TextMessage) m;
                       System.out.println("Reading message: " +
                           message.getText());
                   } else {
                       break;
                   }
               }
           }
       } catch (JMSException e) {
           System.out.println("Exception occurred: " + e.toString());
       } finally {
           if (connection != null) {
               try {
                   connection.close();
               } catch (JMSException e) {
               }
           }
       }
   }

}

Personal tools