Discussions

EJB design: Session Bean as a JMS Message Listener

  1. Session Bean as a JMS Message Listener (11 messages)

    Can someone tell me if this is allowed. I have a stateful session bean that needs to listen to JMS. I know I can't make the ejb listen directly to JMS because of security and transaction reasons. But what if I make a helper class, a regular java class that I register as the message listener. JMS messages will be delivered to the helper class' method and not the beans. It seems to be working so far but I haven't tested it extensively to see if it will cause problems down the road.

    Threaded Messages (11)

  2. Session Bean as a JMS Message Listener[ Go to top ]

    This is an absolutely correct solution.
  3. Session Bean as a JMS Message Listener[ Go to top ]

    I agree with Dimitri, you are doing the right thing Jai. The benefit of your solution is that it will be easy to port it to EJB 2.0 later (which provides message driven beans). Just make sure your helper class is just a "router" of sorts and has no business logic in it.

    Floyd
  4. Session Bean as a JMS Message Listener[ Go to top ]

    Why shouldn't I put business logic in it?
  5. Session Bean as a JMS Message Listener[ Go to top ]

    Because you will not be using many benefits provided by the container, and, for example, if your message processing requires some data modifications it is always better to access your data via EJBs.
  6. Session Bean as a JMS Message Listener[ Go to top ]

    Because if you put business logic in your helper class, you will have to later move it into your EJB's when you use EJB 2.0. In EJB 2.0, you can directly call your EJB's with JMS messages, so there would no longer be a helper class.

    Floyd
  7. Session Bean as a JMS Message Listener[ Go to top ]



    Can you please post the part of your deployment descriptor file (ejb-jar.xml and weblogic-ejb-jar.xml if you are using WL) that maps the topic reference to its jndi name. What xml tag do you use?

    I want to have a session bean (I use a helper class to do the publishing) that is a publisher, but although I can use <ref-resource> as a tag for a TopicConnectionFactory, I cannot use the same tag for a Topic (the WL ejbc compiler complains; says Topic is not an allowed factory...).

    Thanks.

  8. Session Bean as a JMS Message Listener[ Go to top ]

    Here is the mapping from ejb-jar.xml

    <resource-ref>
      <res-ref-name>jms/TopicConnectionFactory</res-ref-name>
      <res-type>javax.jms.TopicConnectionFactory</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>
    <resource-ref>
      <res-ref-name>jms/AlarmTopic</res-ref-name>
      <res-type>javax.jms.Topic</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>


    We use Orion for development. Here is the jms mapping from orion-ejb-jar.xml. I hope this is what you are looking for.

    <resource-ref-mapping name="jms/TopicConnectionFactory" />
    <resource-ref-mapping name="jms/AlarmTopic" />b
  9. Session Bean as a JMS Message Listener[ Go to top ]

    Thanks. That's what I thought it should be. Unfortunately Weblogic complains about it. I get an error from the ejbc compiler:

    ERROR: Error from ejbc: The referenced resource factory type was not one of "javax.sql.DataSource,""javax.jms.QueueConnectionFactory,""javax.jms.TopicConnectionFactory" or "java.net.URL"

    Since I don't get the error with the TopicConnectionFactory but only with the Topic, I know that I'm not doing something wrong.
  10. Session Bean as a JMS Message Listener[ Go to top ]

    May I have an example about JMS listener bean?
  11. Session Bean as a JMS Message Listener[ Go to top ]

    At last I found the thread I was looking for!!! I had posted a similar thread elsewhere with few responses - so I thought I'll just do a brute force search (pending search capability promised by Floyd ;-)) ) & I found it!

    Jai,
    Could you explain your publisher architecture too? As I infer from the thread, you are having your EJB "subscribe" a helper class to a JMS service. Once JMS receives a message, it calls onMessage() on the helper class. Now onMessage() can retrieve the topics & the control is back in the EJB.

    Have I understood it correctly so far?

    Now, how do you do your publishing? I'm also interested to know if you use a Point to Point messaging too.
    Thanks in advance.
    --Das
  12. Session Bean as a JMS Message Listener[ Go to top ]

    Hi Jai,

    I just want to know that is there any need to use third part software like MQseries or SonicMQ for JMS implemetation if I made helper class and all.