1 2 Previous Next 24 Replies Latest reply on Oct 29, 2007 3:15 PM by John Kurtz

    Extensions to EJB3:  Message Driven POJOs

    Bill Burke Master

      We have added an extension for MDBs. Please comment on its usablility and API here. We really need your feedback.

      The description of the feature can be found on our Wiki:

      http://www.jboss.org/wiki/Wiki.jsp?page=MessageDrivenPOJOs

      Thanks,

      Bill

        • 1. Re: Extensions to EJB3:  Message Driven POJOs
          Tolga Tarhan Newbie

          I've only read your Wiki document and I haven't tried it out first-hand yet, but I think this greatly simplifies the development and use of MDB.

          It's also very consistent with the rest of the EJB3 specification. Before these extensions, MDBs seemed like an after-thought in the specification.

          I'd highly recommend including this proposal in the next draft.

          In the meantime, I will try to play with this new extension first-hand (assuming it's been implemented CVS) and give some more feedback after I've had a chance to use it.

          • 2. Re: Extensions to EJB3:  Message Driven POJOs
            Jim Crume Newbie

            I too have only looked at the wiki, but I would agree that anything that simplifies development is a great thing! Is this implemented anywhere I could try it out?

            • 3. Re: Extensions to EJB3:  Message Driven POJOs
              Nadilson Ferreira Newbie

              I've also read just the document and I also haven't tried it out.

              Nevertheless, I have a couple of questions:

              How can I control the type of message that a Producer will produce?
              I mean, in the example we have:
              - TextMessage;
              - ObjectMessage; and so on.

              import org.jboss.ejb3.mdb.ProducerObject;
              import org.jboss.ejb3.mdb.ProducerManager;
              
              public static void main(String[] args) throws Exception
              {
               InitialContext ctx = new InitialContext();
               QueueTestRemote tester = (QueueTestRemote)ctx.lookup(QueueTestRemote.class.getName());
              
               ProducerObject po = (ProducerObject)tester;
               ProducerManager manager = po.getProducerManager();
              
               manager.connect(); // internally create a JMS connection
               try
               {
               tester.method1("hello world", 55);
               }
               finally
               {
               manager.close(); // clean up the JMS connection
               }
              }
              


              I assume the the method tester.method1 will create a JMS message and send it. But how can I define the type of the message?

              Also how can I handle the JMS Message header and stuff like this?

              • 4. Re: Extensions to EJB3:  Message Driven POJOs
                Bill Burke Master

                No way to do either right now. The message type needs to be JBoss controled. Basically I just stuff a JBoss AOP MethodInvocation into an ObjectMessage. As far as the message header, do you mean filters? Also, I'm not sure if filters are a good idea because we are already filtering the message based on the method name. THen again.... Ideas for a simple API to this?

                • 5. Re: Extensions to EJB3:  Message Driven POJOs
                  Carlos Gama Newbie

                  I'm using this extension and I find it very, very useful! It really saves me some time and makes the code more readable/mantainable when implementing message driven beans!

                  Now, I would like to know if there is any way to implement some sort client callbacks? I would like to be able to register some callback method in my message bean (with some annotation like @Callback) as a callback that should be invoked by the server on the remote client whenever a certain method of the server bean is invoked!

                  What do you think about this?

                  Congratulations for your excellent work so far!

                  • 6. Re: Extensions to EJB3:  Message Driven POJOs
                    Bill Burke Master

                    can you show an example in example code?

                    • 7. Re: Extensions to EJB3:  Message Driven POJOs
                      Bill Burke Master

                      can you show an example in example code? This would help to flush the requirements.

                      Also, please repost this onto the EJB 3.0 Development forum. It is more appropriate there.

                      • 8. Re: Extensions to EJB3:  Message Driven POJOs
                        Georges Berscheid Newbie

                        Hi,

                        I just downloaded JBoss4.0.4RC1 and installed EJB3 extensions. Unfortunately, I can't find org.jboss.ejb3.mdb.Consumer or org.jboss.ejb3.mdb.Producer interfaces as described in the wiki. There seem to be implementations to those interfaces in jboss-ejb.jar though.
                        Has this feature been removed?

                        Thanks

                        • 9. Re: Extensions to EJB3:  Message Driven POJOs
                          Bill Burke Master

                          this features is still supported. Can you log a jira task? These should be in the client jars. Apologies

                          • 10. Re: Extensions to EJB3:  Message Driven POJOs
                            Thomas Orr Newbie

                            MDPOJOs rock. I've been working with the api for a little while now. I am debating whether to use it in production code. The fact that the api is so simple is a huge advantage. I do have one question, why does the consumer decide the location of the topic? The ActiveConfgProperty for destination is defined for the consumer in the examples.

                            • 11. Re: Extensions to EJB3:  Message Driven POJOs
                              Bill Burke Master

                              How do you think it should work?

                              • 12. Re: Extensions to EJB3:  Message Driven POJOs
                                Thomas Orr Newbie

                                I would think that the publisher would publish to a topic (define the topic location) and the consumers would subscribe to this topic. I would think that the location of the topic would be defined by the producer of the messages and the consumers would have to listen there. If the consumers define the location, what happens if multiple consumers define different locations?

                                If multiple destinations are not an issue, then I suppose that my entire point is moot. However, if multiple destinations are supported, how are rollbacks handled? I'm correct in assuming that setting the @Producer(connectionFactory = "java:/JmsXA") wil propagate transactions, right?

                                The fact is that documentation is still fairly light. So, I'm not sure if I am using the api to its full potential, or even properly for that matter. That said, it is great overall. It's easy to code to and it just works.

                                • 13. Re: Extensions to EJB3:  Message Driven POJOs
                                  Bill Burke Master

                                  The whole idea is to remove all the lookups and bootstrap code you have to do to obtain and send a message and receive and dispatch a JMS message. With regular JMS you have to

                                  1) Get a connectionfactory
                                  2) Get a connection
                                  3) Get the destination
                                  4) ... and so on.

                                  The idea with MDP's are

                                  1) Get a producer
                                  2) Invoke on producer

                                  What I could do is this:

                                  MyInterface proxy = ProducerHelper.createProxy(connectionFactory, destination, MyInterface.class);
                                  


                                  But that requires the client to lookup the connection faqctory and destination while the current imple, all you have to do is lookup the producer in JNDI.

                                  I guess I could do both. Map out what API you would like and let's talk it through...

                                  • 14. Re: Extensions to EJB3:  Message Driven POJOs
                                    Georges Berscheid Newbie

                                    Ok, turns out the @Producer and @Consumer interfaces have been moved to the org.jboss.annotation.ejb package and ship in server/default/deploy/ejb3.deployer/jboss-annotations-ejb3.jar.
                                    Also, the transactionManagement property in @Consumer (as described in the wiki) seems to have disappeared.
                                    The wiki might need to be updated.

                                    1 2 Previous Next