11 Replies Latest reply on Feb 16, 2011 6:29 AM by Andy Taylor

    Problem while using invm in hornetq

    S ks Newbie

      Hi ,

       

      Iam using Hornetq as my queue solution . Pardon my ignorance iam new to hornetq .

       

      I have

      1) 4 remote clients

      2) 1 Invm client , as in my hornetq server and client run in the same process.

       

      For invm client  iwant to use the netty invm .

      iam not able to set it up correctly:

       

      I used this in my hornetq-configuration.xml file

       

       

          <acceptors>

              <acceptor name="netty-invm">

                  <factory-class>

                      org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory

                  </factory-class>

                  <param key="use-invm" value="true"/>

                  <param key="host" value="${hornetq.remoting.netty.host:localhost}"/>

              </acceptor>

       

              <acceptor name="netty">

                  <factory-class>

                      org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory

                  </factory-class>

                  <param key="host"

                         value="${hornetq.remoting.netty.host:10.14.100.49}"/>

                  <param key="port" value="${hornetq.remoting.netty.port:5445}"/>

              </acceptor>

       

              <acceptor name="netty-throughput">

                  <factory-class>

                      org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory

                  </factory-class>

                  <param key="host"

                         value="${hornetq.remoting.netty.host:10.14.100.49}"/>

                  <param key="port"

                         value="${hornetq.remoting.netty.batch.port:5455}"/>

                  <param key="batch-delay" value="50"/>

                  <param key="direct-deliver" value="false"/>

              </acceptor>

          </acceptors>

       

      I get the following error:

       

      DEPLOYMENTS IN ERROR:

        Deployment "Configuration" is in error due to: java.lang.NumberFormatException: For input string: "10

                  "

       

      DEPLOYMENTS MISSING DEPENDENCIES:

        Deployment "JMSServerManager" is missing the following dependencies:

          Dependency "HornetQServer" (should be in state "Installed", but is actually in state "Described")

        Deployment "HornetQServer" is missing the following dependencies:

          Dependency "Configuration" (should be in state "Installed", but is actually in state "**ERROR**")

       

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:278)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)

          at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:158)

          at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83)

          at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:116)

          at com.inmobi.services.platform.ces.BillableEventService.main(BillableEventService.java:28)

      FAILED::Incompletely deployed:

       

      DEPLOYMENTS IN ERROR:

        Deployment "Configuration" is in error due to: java.lang.NumberFormatException: For input string: "10

                  "

       

      DEPLOYMENTS MISSING DEPENDENCIES:

        Deployment "JMSServerManager" is missing the following dependencies:

          Dependency "HornetQServer" (should be in state "Installed", but is actually in state "Described")

        Deployment "HornetQServer" is missing the following dependencies:

          Dependency "Configuration" (should be in state "Installed", but is actually in state "**ERROR**")

       

      ==================

       

      All my clients are JMS based. How to make sure that my invm client uses the netty invm and all the other clients use remote thingy.

      Pardon my ignorance

        • 1. Problem while using invm in hornetq
          S ks Newbie

          Forgot to mention:

           

          Iam using Hornetq in standalone mode.

          • 2. Problem while using invm in hornetq
            Andy Taylor Master

            theres no such thing as a netty in vm acceptor, we have invm acceptors but they are nothing to do with Netty.

             

            Take a lok at the user manual or any f the examples, all the info yo need is there.

            • 3. Problem while using invm in hornetq
              S ks Newbie

              Thank you for your Reply Andy.

               

              What iam looking for is the feature to be able to do look up in JNDI for acceptor.


              I do not see any example for this. most of the example use

              ConnectionFactory cf = HornetQJMSClient.createConnectionFactory(

                           new TransportConfiguration(InVMConnectorFactory.class.getName()));

                      connection = cf.createConnection();

               

              and directly create the topic and stuff.

               

              I can directly instantiate this but i need a feature to do look up topic from the JNDI

               

              I tried this

              ============

                      try {

                          ConnectionFactory cf = HornetQJMSClient.createConnectionFactory(

                                  new TransportConfiguration(InVMConnectorFactory.class.getName()));

               

                          initialContext = getContext();

               

                          currentTopic = (Topic) initialContext.lookup(topic);

               

                          connection = cf.createConnection();

              =============

               

              But i need some way of setting the Acceptor to the server configuration.

               

              Iam using HornetQBootStrap as a standalone server.

              ====

                          System.out.println(" Initializing the BootStrap server " + args);

                          bootstrap = new HornetQBootstrapServer(new String[]{"hornetq-beans.xml"});

                          bootstrap.run();

                          bootstrap.addShutdownHook();

                          System.out.println("STARTED::");

              =========

              • 4. Problem while using invm in hornetq
                Andy Taylor Master

                looking up an acceptor via jndi does not make sense, do you mean a connection factory?

                 

                if you are using the bootstrap server to start HQ then you need to make sure your config is correct, this is whats causing your errors, look at the example configs and find one that matches your needs.

                 

                Alternatively create the server directly as in the other core examples

                • 5. Problem while using invm in hornetq
                  S ks Newbie

                  Thank you Andy , really appreciate your time , I tried below and it worked.

                   

                  In hornetq-configuration.xml i added

                   

                        <connector name="in-vm">

                           <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>

                           <param key="server-id" value="${hornetq.server-id:0}"/>

                        </connector>

                  under connectors and

                         <acceptor name="in-vm">

                             <factory-class>

                                 org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory

                             </factory-class>

                             <param key="server-id" value="0"/>

                         </acceptor>

                   

                  under acceptors

                   

                  and in hornetq-jms.xml i added this

                      <connection-factory name="InVMConnectionFactory">

                          <connectors>

                              <connector-ref connector-name="in-vm"/>

                          </connectors>

                          <entries>

                              <entry name="java:/ConnectionFactory"/>

                              <entry name="java:/XAConnectionFactory"/>

                          </entries>

                      </connection-factory>

                   

                   

                  I still have 1 question ?

                   

                  From the code point of view i always do

                  ===

                              ConnectionFactory cf =

                                      (ConnectionFactory) initialContext.lookup("/ConnectionFactory");

                  ===

                   

                  So hornetq would automatically know which ConnectionFactory to use ? as in it automatically finds out whether to use InVM or whether to use NettyConnector ?

                   

                   

                  Also i would like to know , if iam planning to use Hornetq as a standalone server in production , but embedded in my product , is using HornetQBootStrap the best way ?

                   

                  regards,

                  rahul

                  • 6. Problem while using invm in hornetq
                    S ks Newbie

                    Hi ,

                     

                    Would  hornetq  automatically know which connector and acceptor to use ? as in it automatically finds out whether to use InVM or whether to use NettyConnector ?

                     

                    From the code i just do the following :

                     

                    ConnectionFactory cf =

                                        (ConnectionFactory) initialContext.lookup("/ConnectionFactory");

                     

                    Is there anything more to be done to tell hornetq to use which connector or acceptor to use? Or my above settings in hornetq-configuration.xml and hornetq-jms.xml is sufficient?

                    • 7. Problem while using invm in hornetq
                      Andy Taylor Master

                      no not automatically, you define it, look at yout connection factory config and you will see that you reference the connector to use, i.e. '<connector-ref connector-name="in-vm"/>'

                      • 8. Problem while using invm in hornetq
                        S ks Newbie

                        Thank you Andy,

                         

                        My question was , in the code do i need to do anything more to make sure that iam using in-vm connector or acceptor? Or by defining it in the configs is sufficient?

                         

                        If i have to do something more in the code , can i get a reference to a document so that i can refer it?

                         

                        regards,

                        rahul

                        • 9. Problem while using invm in hornetq
                          Andy Taylor Master
                          My question was , in the code do i need to do anything more to make sure that iam using in-vm connector or acceptor? Or by defining it in the configs is sufficient?

                          thats what ive just explained, you define a connector, reference it in a connection factory and when you look up the connection factory it will use this type of connector!

                          • 10. Problem while using invm in hornetq
                            S ks Newbie

                            Thank you andy.

                             

                            Iam sorry i think i confused you a little , I have also define below mentioned configs in the configuration too.

                            In hornetq-configuration.xml

                             

                            connectors

                            ============

                                  <connector name="netty">

                                     <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

                                     <param key="host"  value="${hornetq.remoting.netty.host:10.14.100.49}"/>

                                     <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>

                                  </connector>

                             

                            Acceptors

                            ===========

                                  <acceptor name="netty">

                                     <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>

                                     <param key="host"  value="${hornetq.remoting.netty.host:10.14.100.49}"/>

                                     <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>

                                  </acceptor>

                             

                            In hornetq-jms.xml

                            ===

                                <connection-factory name="NettyConnectionFactory">

                                    <connectors>

                                        <connector-ref connector-name="netty"/>

                                    </connectors>

                                    <entries>

                                        <entry name="/ConnectionFactory"/>

                                        <entry name="/XAConnectionFactory"/>

                                    </entries>

                                </connection-factory>

                             

                            This is in addition to the above settings i mentioned earlier. This is the reason i was asking if hornetq automatically finds out which connector or acceptor to pick ?

                            I got these configurations from one of the examples for javaee .

                             

                            I can clearly see that connector-ref is different invm is "in-vm" and netty is "netty" . But for both of them the entries is same as "/ConnectionFactory"  . So when i look up from the initial context i always use just the "/ConnectionFactory" . So does hornetq picks up the correct acceptor or connector. Or do i need to do somehting specifically?

                             

                            regards,

                            rahul

                            • 11. Problem while using invm in hornetq
                              Andy Taylor Master
                              This is in addition to the above settings i mentioned earlier. This is the reason i was asking if hornetq automatically finds out which connector or acceptor to pick ?

                              again, it uses which ever connector you reference from the connector ref.

                              I can clearly see that connector-ref is different invm is "in-vm" and netty is "netty" . But for both of them the entries is same as "/ConnectionFactory"  . So when i look up from the initial context i always use just the "/ConnectionFactory" . So does hornetq picks up the correct acceptor or connector. Or do i need to do somehting specifically?

                              This is where your getting confused, you cant define 2 connection factories with the same jndi reference, each one should be unique