10 Replies Latest reply on Feb 14, 2013 6:02 PM by Justin Bertram

    MessageDrivenBean question

    john gregory Newbie

      I've created and deployed an mdb to a jboss-7as instance I have, after spending time doing this in AS-6.

      In my standalone-full.xml, I created a queue, which when I start the server I see bound to the jndi name I gave it.

       

      Next, I created a MDB.  In testing this when I deployed to AS-6, there was a whole lot of logging that happened

      once the server finished starting.  Specifically, I could see that fact it connected to the queue and that the

      was no user specified.  However, when I take this same MDB and deploy it to AS-7, the only thing I see is that

      the bean successfully deployed -- no additional logging like in AS-6.  Furthermore, I have a @PostConstruct

      annotation with an init() which spits out logging.  I could see this happening in AS-6, but in AS-7, you can almost

      hear the crickets chirp as I'm searching for it.

       

      I'm wondering whether it's a configuration issue or something else.  I've taken my AS-6 hornetq files and attempted

      to conform them to AS-7 and it's configuration, but I'll buy that I might have missed something.  Any suggestions

      would be VERY WELCOME.

       

      Thanks,

       

      John

        • 1. Re: MessageDrivenBean question
          Justin Bertram Master

          The deployment and construction of the MDB actually has very little to do with HornetQ, at least until the MDB gets wired to the HornetQ JCA Resource Adapter. 

           

          I'm not clear on specifically what logging you saw in AS6 that you're not seeing now in AS7.  Can you clarify this point?

           

          As far as your application logging that a completely unrelated to HornetQ that someone else will have to comment on.

           

          What happens when you send a message to the JMS destination where the MDB is listening?  Is the message consumed?

          • 2. Re: MessageDrivenBean question
            john gregory Newbie

            Justin,

             

            Ok, I have jboss 6 installed on 2 different servers.  The one with the mdb deployed spits out a lot of sql/hibernate related logging

            going on that doesn't happen when I start jboss 6 on the other server (one without the mdb deployed).  On the server with the

            mdb deployed, if I remove the deployment and bounce the server, it behaves the same as the other one, none of the sql/hibernate

            related logging...not sure if it's related, or what.

             

            As for consuming messages, in jboss 6, I can.  However, when switching to jboss 7, I'm having to sort through some binding

            issues - when I do a netstat -an | grep 1099, I get a connection refused.  there's a ton of documentation I'm wading through to

            see what may be the cause of this

             

            John

            • 3. Re: MessageDrivenBean question
              Justin Bertram Master

              I can't really help you with the logging stuff.  If you really want to get to the bottom of it then I suggest you start a new thread which deals specifically with your logging question(s).

               

              Regarding port 1099, AS7 doesn't use port 1099 for anything.  Are you trying to do a JNDI lookup from a remote client?  If so, what are you trying to lookup?  It may help to review the AS7 JMS quickstart if you're trying to do JMS work from a remote client.

              • 4. Re: MessageDrivenBean question
                john gregory Newbie

                Justin,

                 

                No need to open a new thread...I was just using as a basis for attempting to determine whether the deployment was successful and the bean was bound to the queue.

                 

                As for the client...this first one is local to the box, but the goal is to eventually have a remote client (web and/or command line).  You were helping me with this awhile

                ago, but this got pushed off while I was working other issues.  Now that that's done, I'm starting back down this road.  Since we are behind a firewall, I have a request into

                our network team to get port 4447 opened.  From the documentation I've read, that's the hornetq remote jndi port...is this correct? 

                 

                Just to get a jump on things, what would my provider_url look like?  I'm on an isolated network, so any examples/code snippets I'll have to hand poke across the domains.

                I'm guessing it'd be jnp:/<hostname>:4447 ??? Is this correct?

                 

                Thanks for the assistance here!

                 

                John

                • 5. Re: MessageDrivenBean question
                  Justin Bertram Master

                  Since we are behind a firewall, I have a request into our network team to get port 4447 opened.  From the documentation I've read, that's the hornetq remote jndi port...is this correct?

                  Port 4447 is used for JNDI which isn't really tied to HornetQ in any way.  You can look up JMS connection factories and destinations in JNDI and you'll receive the HornetQ implementations of these.  However, once these are looked up in JNDI the HornetQ/JMS client will communicate with the server on port 5445 by default so you'll need that one open on your firewall as well.

                   

                   

                  I'm guessing it'd be jnp:/<hostname>:4447 ??? Is this correct?

                  No, that's not correct.  Take a look at the link I provided in my previous comment for AS7 JMS quickstart.

                  • 6. Re: MessageDrivenBean question
                    john gregory Newbie

                    Justin,

                     

                    We've been exchanging periodic emails about jboss & embedded hornetq with a remote client.

                    I've not been able to get this working, and I'm lost as to why.  On the jboss/hornetq side, I've

                    configured my standalone-full.xml file with the name of the queue - I see the bound jndi name when

                    the server starts, so this appears to be ok.

                     

                    Next, I've developed a very simple MDB and placed the jar file in the standalone/deployments directory.

                    Again, when the server starts, I can see where it says my mdb was started with hornetq-ra resource

                    adapter, so too, this appears to be ok.

                     

                    The problem is on my client.  I've scouraged for every example of a jboss/hornetq embedded server

                    sending to a remote client.  In this post, https://community.jboss.org/thread/215553 it seemed this

                    person had a similar issue and you directed him to:

                    https://github.com/jboss-jdf/jboss-as-quickstart/blob/jdf-2.0.0.Final/helloworld-jms/src/main/java/org/jboss/as/quickstarts/jms/HelloWorldJMSClient.java

                    The bind url in the initial context used  remote://localhost:4447 which is what I'm currently using in my

                    client.  However, this gives me the error described here:  https://community.jboss.org/thread/215553

                     

                    When I change the url to the machine name, the initial context gets created, however, it bombs out doing a jndi lookup on

                    the connection factory (presently, it is set at /RemoteConnectionFactory).  Originally, it was set to java:/RemoteConnectionFactory,

                    which is what I see in the logs when the server starts.  However, whatever name I use, I get a NameNotFoundException.

                    Everything thereafter, bombs out...  Any idea what I may be doing wrong?  It has to be something, otherwise I wouldn't

                    need to post anything. 

                     

                    Thanks,

                     

                    John

                    • 7. Re: MessageDrivenBean question
                      Justin Bertram Master

                      The problem is on my client.  I've scouraged for every example of a jboss/hornetq embedded server sending to a remote client.  In this post, https://community.jboss.org/thread/215553 it seemed this person had a similar issue and you directed him to: https://github.com/jboss-jdf/jboss-as-quickstart/blob/jdf-2.0.0.Final/helloworld-jms/src/main/java/org/jboss/as/quickstarts/jms/HelloWorldJMSClient.java

                      For the record, I've referred you to the HelloWorldJMSClient twice on this thread alone.  The first time here, and then again here.  Have you downloaded it and got it working or at least reviewed it?  It is a working example of a remote JMS client sending messages to HornetQ embedded with JBoss AS7.  Is that not exactly what you're trying to do?

                       

                      The bind url in the initial context used  remote://localhost:4447 which is what I'm currently using in my

                      client.  However, this gives me the error described here:  https://community.jboss.org/thread/215553

                      Which error exactly?  The user in that thread had a JMS client hosted in JBoss AS7 that was attempting to connect to a remote standalone instance of HornetQ.  Is this your use-case?

                       

                      When I change the url to the machine name, the initial context gets created, however, it bombs out doing a jndi lookup on the connection factory (presently, it is set at /RemoteConnectionFactory).  Originally, it was set to java:/RemoteConnectionFactory, which is what I see in the logs when the server starts.  However, whatever name I use, I get a NameNotFoundException.  Everything thereafter, bombs out...  Any idea what I may be doing wrong?

                      When you say "it bombs out" do you mean that you're always getting a NameNotFoundException?  Do you ever get other kinds of exceptions?  You need to be specific.  Saying "it bombs out" isn't particularly helpful.

                       

                      If you're using the default HornetQ configuration then neither "/RemoteConnectionFactory" nor "java:/RemoteConnectionFactory" is the proper JNDI lookup.  You should use "jms/RemoteConnectionFactory" just like the AS7 JMS quickstart that I've cited several times now.

                      1 of 1 people found this helpful
                      • 8. Re: MessageDrivenBean question
                        john gregory Newbie

                        Justin,

                         

                        Yes, I've looked at the example you pointed me towards and modified my

                        code to mimic that, with some slight differences.

                         

                        they are:

                         

                        a) server name/url.  In the example, they use remote://localhost:4447.  If I use this

                        url, I see this exception:

                         

                        javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException:

                        Operation failed with status WAITING]

                        at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

                        at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)

                        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

                        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

                        at javax.naming.InitialContext.init(InitialContext.java:223)

                        at javax.naming.InitialContext.<init>(InitialContext.java:197)

                         

                        However, if I use the machine name, labmachine25, and url of:

                        remote://labmachine25:4447 the initial context gets created and I can proceed.

                         

                        Now that I've got an initial context, I can move to getting a connection factory.

                         

                        b) In my code, the jndi name I used for my connection factory is

                        java:/RemoteConnectionFactory.  In your latest response, you state I

                        should use jms/RemoteConnectionFactory. Ok, I tried this and I got a bit

                        further, but why would I think to use this.  This bound name appears

                        NOWHERE in my environment...  A thorough search of the logs doesn't show it and

                        more importantly, when a view the "JNDI View" through the admin console, this

                        entry is not there. 

                         

                        c) same issue with the name of my queue.  In the example, the name is jms/queue/test.

                        I am able to successfully find this object, which has no binding anywhere that I can

                        see.  As with the connection factory, I assumed it to be the boud name in the example

                        environment.

                         

                        d) with the username/password, I assumed that to be an entry in the flie

                        application.users.properties.  When I substitute the values in the example,

                        an exception ensues and the connection is not created.  I've tried creating

                        a connection with/without the username/password combo.  All times it is

                        null

                         

                        When I say everything bombs out, it's NameNotFoundException/JMSException for

                        some of the artifacts that are not created.

                         

                        SO, I'm not sure where to go from here....I guess one question I have is how do I

                        translate bound jndi names to something that'll work?

                         

                        John

                        • 9. Re: MessageDrivenBean question
                          Justin Bertram Master

                          a) server name/url.  In the example, they use remote://localhost:4447.  If I use this url, I see this exception:

                           

                          javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException:

                          Operation failed with status WAITING]

                          at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

                          at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)

                          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

                          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

                          at javax.naming.InitialContext.init(InitialContext.java:223)

                          at javax.naming.InitialContext.<init>(InitialContext.java:197)

                           

                          However, if I use the machine name, labmachine25, and url of:

                          remote://labmachine25:4447 the initial context gets created and I can proceed.

                          That suggests you are not binding your JBoss AS instance to the "localhost" network interface but rather to the "labmachine25" network interface.

                           

                          In your latest response, you state I should use jms/RemoteConnectionFactory. Ok, I tried this and I got a bit further, but why would I think to use this.  This bound name appears NOWHERE in my environment...

                          Are you sure about that?  It wouldn't work if wasn't configure that way (which it is by default).  Remember, JNDI names bound in the server need to be bound in the "java:/jboss/exported" namespace to be available to remote clients.  For example, this is the default "RemoteConnectionFactory" definition:

                           

                                              <connection-factory name="RemoteConnectionFactory">
                                                  <connectors>
                                                      <connector-ref connector-name="netty"/>
                                                  </connectors>
                                                  <entries>
                                                      <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                                                  </entries>
                                              </connection-factory>
                          

                           

                          These semantics are explained in the messaging subsystem documentation.  It's also mentioned in the JNDI Reference.

                           

                          A thorough search of the logs doesn't show it...

                          When I start the server I see this in the log:

                           

                          INFO  [org.jboss.as.messaging] (pool-4-thread-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
                          

                           

                           

                          ...more importantly, when a view the "JNDI View" through the admin console, this entry is not there.

                          I can't speak to this point.  I don't know if the java:jboss/exported namespace is reported the same way as other namespaces in the JNDI view.  I recommend you start another thread to explore this issue if you like.

                           

                           

                          c) same issue with the name of my queue.  In the example, the name is jms/queue/test.  I am able to successfully find this object, which has no binding anywhere that I can see.

                          My guess is that your queue is defined like this:

                           

                                 <jms-queue name="testQueue">
                                     <entry name="jms/queue/test"/>
                                     <entry name="java:jboss/exported/jms/queue/test"/>
                                 </jms-queue>
                          

                           

                          Notice the "entry" whose "name" is "java:jboss/exported/jms/queue/test".  That makes it available to remote clients with the same semantics as described above and also covered in the documentation I cited previously.

                           

                           

                          d) with the username/password, I assumed that to be an entry in the flie application.users.properties.  When I substitute the values in the example, an exception ensues and the connection is not created.  I've tried creating a connection with/without the username/password combo.  All times it is null

                          This is basic security configuration.  Both JNDI and JMS are secured by default so you'll have to set up the proper user on the server and then pass in those credentials when you perform the JNDI lookup and create the JMS connection.  A lot (if not all) of this is covered in the documentation for the quickstart I pointed you to previously.

                           

                           

                          SO, I'm not sure where to go from here....I guess one question I have is how do I translate bound jndi names to something that'll work?

                          Read the documentation.  Read the JMS quickstart. 

                          • 10. Re: MessageDrivenBean question
                            Justin Bertram Master

                            BTW - For the JNDI issue where you can't see the stuff in the "java:/jboss/exported" namespace I think you're probably hitting https://issues.jboss.org/browse/AS7-5515.