Results 1 to 4 of 4

Thread: Websphere and Spring JMS how to load the context

  1. #1
    Join Date
    Jul 2008
    Location
    Dublin
    Posts
    16

    Default Websphere and Spring JMS how to load the context

    Hi all,
    I'm a big fan of Spring and have used its transaction, IOC and MVC components for web development in Tomcat.

    I'm now looking at using JMS to receive and reply to messages received via MQ on Websphere. I noticed that Spring has a JMS package and I'd like to use it.

    I can get the standalone example from the below link working.

    blog.springsource.com/main/2006/08/11/message-driven-pojos/

    I know when I'm using Webspheres MQ I'll look up the queues and connection factory using JNDI.

    My question is how in websphere do I start the spring context.

    When its standalone I just run the following (From above link)

    public static void main(String[] args) throws IOException {
    new ClassPathXmlApplicationContext("/blog/mdp/server-context.xml");
    System.in.read();
    }

    Do I need to deploy a EJB to websphere and use its lifecycle to start the Spring context

    I'm quite new to the JMS world so any help would be greatly appreciated.

    Michael

  2. #2
    Join Date
    May 2007
    Location
    Istanbul
    Posts
    42

    Default

    1- You can use WebSphere extension startup beans if you want to initialize the context immediately (As soon as application starts). But startup beans are not supported in Ejb3. You have to have ejb2 module.

    2- You can initialize the context with ClasspathXmlApplicationContext like you did in standalone application. Create a ContextLocator class, keep a AppliationContext reference in it, and in getter method of this reference, check for it is already initialized or not, if not initialized, instantiate the context with xml config file parameters.

    3- You can initialize the context with ContextSingletonBeanFactoryLocator, you're gonna access the context with this class, and it will initialize the context on first request. But you should have beanRefContext.xml on your classpath.

    4- Create a web module, and use ContextLoaderListener.
    Senior Consultant
    Turkiye Is Bankasi

  3. #3
    Join Date
    Jul 2008
    Location
    Dublin
    Posts
    16

    Default

    Thanks Burki

    Quote Originally Posted by burki View Post
    1- You can use WebSphere extension startup beans if you want to initialize the context immediately (As soon as application starts). But startup beans are not supported in Ejb3. You have to have ejb2 module.
    Its websphere 6.1 so this seems like a possible option

    Quote Originally Posted by burki View Post
    2- You can initialize the context with ClasspathXmlApplicationContext like you did in standalone application. Create a ContextLocator class, keep a AppliationContext reference in it, and in getter method of this reference, check for it is already initialized or not, if not initialized, instantiate the context with xml config file parameters.
    Ok so In this case would you have a EJB too (Startup bean). Am I right in thinking you either need an EJB or a Webapp to deploy Spring JMS to websphere?

    Quote Originally Posted by burki View Post
    3- You can initialize the context with ContextSingletonBeanFactoryLocator, you're gonna access the context with this class, and it will initialize the context on first request. But you should have beanRefContext.xml on your classpath.
    Again this would happen from an EJB?

    Quote Originally Posted by burki View Post
    4- Create a web module, and use ContextLoaderListener.
    Is this best practice for Spring JMS or is really up to individual preference?

    Thanks again for the reply you have given me quite a few options to look into.

    Michael
    Last edited by mikfreeman; Jul 4th, 2008 at 02:19 AM. Reason: Forgot quote tag

  4. #4
    Join Date
    Jul 2008
    Location
    Dublin
    Posts
    16

    Default

    Just thought I'd update the thread.

    I'm starting the context using a Startup bean.

    In RAD 7 you create a session bean and specify

    com.ibm.websphere.startupservice.AppStartUpHome

    As the remote home interface

    and

    com.ibm.websphere.startupservice.AppStartUp

    as the remote interface.

    Then in your session bean just add start and stop methods.

    The start method should return a boolean indicating if start up was successful.

    Make sure you enable the startup bean service using websphere admin console or they won't work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •