users@glassfish.java.net

Re: Embedded JMS not starting automatically

From: <glassfish_at_javadesktop.org>
Date: Thu, 15 Jul 2010 06:13:13 PDT

Hi Nigel that would be much appreciated

In the meantime I wrote a litte EJB class that will kickstart the JMS service into life... its crude but it works

package messaging.kickstart;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.jms.ConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author tsparg
 */
@Singleton
@Startup
public class KickStartBean {

    @PostConstruct
    public void initMessaging(){
        try {
            Context context = new InitialContext();
            ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("JMSInitPool");
            Logger.getLogger(KickStartBean.class.getName()).log(Level.INFO,
                    "JMS HAS INITIALIZED");
        } catch (NamingException ex) {
            Logger.getLogger(KickStartBean.class.getName()).log(Level.SEVERE,
                    "JMS HAS FAILED TO INITIALIZED", ex);
        }

    }
}
[Message sent by forum member 'timsa']

http://forums.java.net/jive/thread.jspa?messageID=477728