11 Replies Latest reply on Apr 23, 2014 8:33 AM by Yair Ogen

    problem running embedded sample on HornetQ 2.4.1

    Yair Ogen Expert

      I'm trying to run the following sample, but it fails on:

       

      HornetQNotConnectedException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

        at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:905)

       

             EmbeddedHornetQ embedded = new EmbeddedHornetQ();
              embedded.start();
      
      
              ClientSessionFactory nettyFactory = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())).createSessionFactory();
      
      
              ClientSession session = nettyFactory.createSession();
      
      
              session.start();
      
      
              session.createQueue("example", "example", true);
      
      
              ClientProducer producer = session.createProducer("example");
      
      
              ClientMessage message = session.createMessage(true);
      
      
              message.getBodyBuffer().writeString("Hello");
      
      
              producer.send(message);
      
      
              session.start();
      
      
              ClientConsumer consumer = session.createConsumer("example");
      
      
              ClientMessage msgReceived = consumer.receive();
      
      
              System.out.println("message = " + msgReceived.getBodyBuffer().readString());
      
      
              session.close();
      
        • 1. Re: problem running embedded sample on HornetQ 2.4.1
          Andy Taylor Master

          have you created the appropriate acceptors in your hornetq-configuration.xml

          • 2. Re: problem running embedded sample on HornetQ 2.4.1
            Justin Bertram Master

            You might try looking at the embedded example we ship with HornetQ.  It's in the examples/core/embedded directory in our distribution.

            • 3. Re: problem running embedded sample on HornetQ 2.4.1
              Yair Ogen Expert

              The examples don't contain a configuration example only source code. Where can I find info on embedded acceptors configuration?

              • 4. Re: problem running embedded sample on HornetQ 2.4.1
                Justin Bertram Master

                There are 2 embedded examples shipped with HornetQ:

                1. embedded
                2. embedded-simple

                 

                The first is an example of programmatic configuration.  There are no configuration files, just code.

                 

                The second is an example of file-based configuration.  There are configuration files and code.

                1 of 1 people found this helpful
                • 5. Re: problem running embedded sample on HornetQ 2.4.1
                  Yair Ogen Expert

                  Thanks, I see that embedded-simple is for jms. I'm looking for example of embedded using core and file based configuration. Can you help?

                  • 7. Re: Re: problem running embedded sample on HornetQ 2.4.1
                    Yair Ogen Expert

                    Huh?

                     

                    I've tried the code in the above first post with the below configuration file. doesn't work.

                     

                    <configuration xmlns="urn:hornetq"
                                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                   xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
                    
                    
                       <paging-directory>${data.dir:../data}/paging</paging-directory>
                       
                       <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
                       
                       <journal-directory>${data.dir:../data}/journal</journal-directory>
                       
                       <journal-min-files>10</journal-min-files>
                       
                       <large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>
                       
                       <connectors>
                          <connector name="netty">
                             <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
                             <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>
                             <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
                          </connector>
                          
                          <connector name="netty-throughput">
                             <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
                             <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>
                             <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>
                             <param key="batch-delay" value="50"/>
                          </connector>
                       </connectors>
                    
                    
                       <acceptors>
                          <acceptor name="netty">
                             <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
                             <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>
                             <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:localhost}"/>
                             <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>
                             <param key="batch-delay" value="50"/>
                             <param key="direct-deliver" value="false"/>
                          </acceptor>
                       </acceptors>
                    
                    
                       <security-settings>
                          <security-setting match="#">
                             <permission type="createNonDurableQueue" roles="guest"/>
                             <permission type="deleteNonDurableQueue" roles="guest"/>
                             <permission type="consume" roles="guest"/>
                             <permission type="send" roles="guest"/>
                          </security-setting>
                       </security-settings>
                    
                    
                       <address-settings>
                          <!--default for catch all-->
                          <address-setting match="#">
                             <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                             <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                             <redelivery-delay>0</redelivery-delay>
                             <max-size-bytes>10485760</max-size-bytes>       
                             <message-counter-history-day-limit>10</message-counter-history-day-limit>
                             <address-full-policy>BLOCK</address-full-policy>
                          </address-setting>
                       </address-settings>
                    
                    
                    </configuration>
                    
                    
                    
                    • 8. Re: Re: problem running embedded sample on HornetQ 2.4.1
                      Justin Bertram Master

                      What's the name of your configuration file?  Is it hornetq-configuration.xml?  If so, is it on your classpath?  By default org.hornetq.core.server.embedded.EmbeddedHornetQ will load hornetq-configuration.xml from the classpath.  If it's named differently or not on your classpath then you'll need to invoke setConfigResourcePath(String) as appropriate.

                      • 9. Re: Re: problem running embedded sample on HornetQ 2.4.1
                        Yair Ogen Expert

                        Yes and Yes. The right file name and it is in the classpath. Verified by changing the file name to "hornetq-configuration-1.xml" and then I see this error:

                         

                        java.net.MalformedURLException: no protocol: hornetq-configuration.xml

                         

                        So the file name was right and reverting back to "hornetq-configuration.xml" but it still fails on:

                         

                        HornetQNotConnectedException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

                          at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:905)

                        • 10. Re: Re: Re: problem running embedded sample on HornetQ 2.4.1
                          Justin Bertram Master

                          I believe I see the issue now.  Although you call it "nettyFactory" you are actually trying to connect using an in-vm connector, e.g.:

                          ClientSessionFactory nettyFactory = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())).createSessionFactory();

                           

                          However, your configuration doesn't have an in-vm acceptor.  Andy asked you about this in the first response on this thread almost 2 weeks ago.

                          • 11. Re: Re: problem running embedded sample on HornetQ 2.4.1
                            Yair Ogen Expert

                            I Probably missed that. Can you please share a in-vm acceptor configuration?


                            I tried adding:


                            <acceptor name="in-vm">
                                       <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
                                   </acceptor>
                            
                            


                            But this resulted with:


                            HornetQSecurityException[errorType=SECURITY_EXCEPTION message=HQ119031: Unable to validate user: null]

                              at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:394)

                             

                            Adding the following resolved my issue and tests finally passes:


                            <security-enabled>false</security-enabled>