12 Replies Latest reply on Jan 18, 2005 12:06 PM by Bernd Zeitler

    Integrating MMS server with jboss 3.2.5

    Eitan Gur Newbie

      Hi

      I'm using a small server for receiving mms messages. I want to integrate it with my jboss AS (jboss-3.2.5), so I could start and stop it through the jmx console.
      I managed to integrate it using the WRONG way of creating a new thread for it, but when I tried implementing it directly - it seems as if the server is blocking on I/O.

      Any ideas?

        • 1. Re: Integrating MMS server with jboss 3.2.5
          Eitan Gur Newbie

          I want to add more details:

          The need to integrate the MMS server with the AS is more than just start/stop buttons, as I need to get data from the received mms and pass it to componenets in my AS.

          The basic flow should be like this:

          AS running and doing what it needs (forever...)
          While MMS server is started do:
           listen to MMS messages (concurrently with the AS regular flow)
           Once an MMS message arrives , perform:
           Accept it
           Move it to AS
           Keep listening to other MMS messages
          until MMS server is stopped


          • 2. Re: Integrating MMS server with jboss 3.2.5
            Bernd Zeitler Expert

            Something like that is usually done by writing a MBean. If you don't know how to do this, read the JBoss doko, search the forum and the wiki since this has been specified pretty good.

            • 3. Re: Integrating MMS server with jboss 3.2.5
              Eitan Gur Newbie

              I tried to do so, but this causes the AS to stop responding, as it is constantly waiting for messages in a loop.

              • 4. Re: Integrating MMS server with jboss 3.2.5
                Bernd Zeitler Expert

                If your implementation is working as POJO implementation, it will work as MBean, too.

                You didn't implement the loop above within the start service method, did you? You will block the jmx server when the start method doesn't return.

                You must do this within your own thread. What was wrong with this solution?

                • 5. Re: Integrating MMS server with jboss 3.2.5
                  Eitan Gur Newbie

                  The problem is that threads are not supposed to be managed by me:
                  ejb2.1 spec chapter 25.1.2

                  The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt
                  to start, stop, suspend, or resume a thread, or to change a thread?s priority or name. The enterprise
                  bean must not attempt to manage thread groups.


                  • 6. Re: Integrating MMS server with jboss 3.2.5
                    Bernd Zeitler Expert

                    MBeans are not EJBs. The thread(s) must be managed in there!!!!!

                    • 7. Re: Integrating MMS server with jboss 3.2.5
                      Eitan Gur Newbie

                      from the book effective enterprise java

                      In order to maintain a system that?s as scalable as possible, the container seeks to take on resource management as part of its duties. It does this because, as a unifying force across all sorts of different programs and enterprise systems, the container often has a better picture of what the overall resource needs are, as opposed to your code?s rather localized view of the world.
                      But now you start firing up threads from your servlets. Because the servlet specification provides no way for a servlet developer to integrate with the servlet container?s thread-management scheme, these threads are, by definition, outside the servlet container?s control. So if the system administrator sets a thread pool limit of N threads in the servlet container because he?s figured out, after much tuning and testing, that N is the optimal number for this particular container and platform, the underlying virtual machine is actually running N + 1 threads-the N threads the servlet container knows about, and the 1 that it doesn?t, your servlet?s thread. Suddenly, you?re past the point of optimal usage, and starting down the road of diminishing returns. If that ?1? becomes ?2? or more, this could very quickly get into a situation where the thread-switching time outnumbers the actual work time


                      Now this quote relates to servlets specifically, but the main idea is the same. If I configure the container to work with N threads, and I start adding threads manually - the optimization I conducted is now lost...

                      • 8. Re: Integrating MMS server with jboss 3.2.5
                        Bernd Zeitler Expert

                        Where is the problem?
                        It is up to you where you are going to obtain threads (e.g. thread pools). The number of threads can (usually) be configured with the service since configuring this makes only sense per service (in your example the web service). And remember, you are going to provide a service which needs at least one thread because your are "listening to MMS messages"...

                        • 9. Re: Integrating MMS server with jboss 3.2.5
                          dannyb23 Newbie

                          how can one fire up a thread in a "legitimate way" while being inside a j2ee container?!

                          • 10. Re: Integrating MMS server with jboss 3.2.5
                            Bernd Zeitler Expert

                            Danny, I was talking about MBeans, did you read this thread????

                            MBeans are not EJBs. The thread(s) must be managed in there!!!!!

                            RTFM

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

                            MBEans are services. The EJB container within jboss is based on services (MBeans), too. This has NOTHING to do with J2EE.

                            • 11. Re: Integrating MMS server with jboss 3.2.5
                              dannyb23 Newbie

                              I'm talking about MBeans as well.
                              MBeans are living inside a j2ee container.
                              its not recommanded to start your own threads when you are living in a j2ee container, the container should be responsible of threads managment.

                              can you give an example of a legitimate way to start threads while living in a j2ee container? (for example his server thread)...

                              10x

                              • 12. Re: Integrating MMS server with jboss 3.2.5
                                Bernd Zeitler Expert

                                This thread should be moved to "useless rants" soon...

                                What does "live inside a j2ee container" mean? Does every object instanciated within the vm started with jboss "live inside a j2ee container"?
                                JBoss is a multi-tier application based on a jmx microkernel. What parts "live inside a j2ee container"?

                                Probably I should have written "deal with threads" instead of "manage threads". The jboss web service is a service dealing with and managing thread. Is this "legitim"?

                                Myl "where-is-the-problem-answer" is still valid... no problem at all.