10 Replies Latest reply on Jun 14, 2011 11:21 AM by ronsen

    Message "broadcasting"

    ronsen

      How would it be implemented to have a cluster with lets say 5 nodes. A client sends messages to a message-queue on node1 and node1 spreads/broadcasts/sends the messages to the other 4 nodes (consumers) that have to deal with the messages and keep on working.

       

      - How would this be implemented at best?

           - My Idea would be to have listeners on the 4 servers (ejb) with message driven beans that consume the messages from node1 or something.

      - Would it be balanced to the 4 nodes automatically?

           - In that case would they consume as many messages as their cpu load allows?!

        • 1. Re: Message "broadcasting"
          clebert.suconic

          All of our clustering examples are doing this kind of thing with either JMS topics or JMS Queues.. (and with the core-api also).

          • 2. Re: Message "broadcasting"
            ronsen

            got a link? hornetq or jboss examples?

            • 3. Re: Message "broadcasting"
              clebert.suconic

              Look at the examples on the hornetq distribution.

              • 4. Re: Message "broadcasting"
                ronsen

                I tried to work according to the examples to test something, but for some reason the lookup of the queue as well as the lookup of the connection factory doesnt work adn drops this:

                 

                javax.naming.CommunicationException

                 

                [Root exception is java.rmi.UnmarshalException

                : error unmarshalling return; nested exception is:

                 

                 

                java.lang.ClassNotFoundException

                : org.hornetq.jms.referenceable.SerializableObjectRefAddr (no security manager: RMI class loader disabled)]

                at org.jnp.interfaces.NamingContext.lookup(

                 

                NamingContext.java:841

                )

                at org.jnp.interfaces.NamingContext.lookup(

                 

                NamingContext.java:688

                )

                at javax.naming.InitialContext.lookup(Unknown Source)

                at jma.client.Producer.main(

                 

                Producer.java:37

                )

                Caused by:

                 

                java.rmi.UnmarshalException

                : error unmarshalling return; nested exception is:

                 

                 

                java.lang.ClassNotFoundException

                : org.hornetq.jms.referenceable.SerializableObjectRefAddr (no security manager: RMI class loader disabled)

                at sun.rmi.server.UnicastRef.invoke(Unknown Source)

                at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)

                at org.jnp.interfaces.NamingContext.lookup(

                 

                NamingContext.java:728

                )

                ... 3 more

                 

                the corresponding line is:

                 

                ConnectionFactory f = (ConnectionFactory)

                ctx.lookup("/ConnectionFactory");

                 

                queue = (Queue)ctx.lookup("queue/testQueue");

                 

                 

                 

                 

                @MessageDriven

                 

                (name = "MDBExample"

                ,

                activationConfig =

                {

                 

                @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"

                ),

                 

                @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"

                ),

                })

                @ResourceAdapter

                 

                ("hornetq-ra.rar"

                )

                 

                the order of them doesnt change anything.

                 

                 

                In my "consumer class":

                 

                 

                 

                 

                 

                 

                Together with:

                 

                 

                 

                 

                 

                public void

                onMessage(Message message) {

                 

                try

                {

                TextMessage textMessage = (TextMessage)message;

                 

                String text = textMessage.getText();

                 

                System.

                out.println("Message: "

                + text);

                 

                }

                catch

                (Exception e){

                e.printStackTrace();

                 

                }

                }

                 

                Any idea?

                 

                Thanks in advance,

                 

                 

                Edit:

                ________________________________

                 

                e.printStackTrace();

                 

                }

                }

                 

                Any idea?

                 

                Thanks in advance,

                 

                 

                Edit:

                ________________________________

                 

                1. <queue name="testQueue">
                2. <entry name="/queue/testQueue"/>
                3. </queue>

                4. added this as well to my config.

                • 5. Re: Message "broadcasting"
                  ronsen

                  Btw. the wysiwyg here sucks -.- .....if i copy stuff and try to paste it, it usually breaks up everything or just pastes half of tehz content etc...

                  • 6. Re: Message "broadcasting"
                    ronsen

                    Ok for some reason some of the libs were missing after all it looks like this:

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                    Exception in thread "main"

                     

                    javax.naming.NamingException: Could not dereference object [Root exception is java.io.InvalidClassException

                    : org.hornetq.core.client.impl.ClientSessionFactoryImpl; org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization]

                    at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(

                     

                    NamingContext.java:1508

                    )

                    at org.jnp.interfaces.NamingContext.lookup(

                     

                    NamingContext.java:824

                    )

                    at org.jnp.interfaces.NamingContext.lookup(

                     

                    NamingContext.java:688

                    )

                    at javax.naming.InitialContext.lookup(Unknown Source)

                    at jma.client.Producer.main(

                     

                    Producer.java:38

                    )

                    Caused by:

                     

                    java.io.InvalidClassException

                    : org.hornetq.core.client.impl.ClientSessionFactoryImpl; org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization

                    at java.io.ObjectStreamClass.checkDeserialize(Unknown Source)

                    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

                    at java.io.ObjectInputStream.readObject0(Unknown Source)

                    at java.io.ObjectInputStream.defaultReadFields(Unknown Source)

                    at java.io.ObjectInputStream.readSerialData(Unknown Source)

                    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

                    at java.io.ObjectInputStream.readObject0(Unknown Source)

                    at java.io.ObjectInputStream.readObject(Unknown Source)

                    at org.hornetq.jms.referenceable.SerializableObjectRefAddr.deserialize(

                     

                    SerializableObjectRefAddr.java:79

                    )

                    at org.hornetq.jms.referenceable.ConnectionFactoryObjectFactory.getObjectInstance(

                     

                    ConnectionFactoryObjectFactory.java:43

                    )

                    at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)

                    at org.jnp.interfaces.NamingContext.getObjectInstance(

                     

                    NamingContext.java:1483

                    )

                    at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(

                     

                    NamingContext.java:1500

                    )

                    ... 4 more

                    Caused by:

                     

                    java.io.InvalidClassException

                    : org.hornetq.core.client.impl.ClientSessionFactoryImpl; class invalid for deserialization

                    at java.io.ObjectStreamClass.initNonProxy(Unknown Source)

                    at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)

                    at java.io.ObjectInputStream.readClassDesc(Unknown Source)

                    ... 16 more

                     

                     

                     

                     

                    referring to this line:

                     

                    ConnectionFactory f = (ConnectionFactory) ctx.lookup(

                    "/ConnectionFactory"

                    );

                    • 7. Re: Message "broadcasting"
                      ataylor

                      I think thats a classpath issue with jboss, i think ive seen something like this before, google should find it

                      • 8. Re: Message "broadcasting"
                        ronsen

                        i actually added EVERYTHING from the libs to it...

                        • 9. Re: Message "broadcasting"
                          clebert.suconic

                          @Ron There's definitely something missing in your classpath. Either missing or you have wrong versions there on your client/lib

                          • 10. Re: Message "broadcasting"
                            ronsen

                            Checked it all and finally found the bad guy hiding in the classpath as you said... I mixed up some of the jboss libs with the libs from the current hornetQ distribution. Due to that there were some mismatches in them.

                             

                            Thanks a lot for rubbing it under my nose ;-)

                             

                            greets