1 Reply Latest reply on Mar 28, 2012 5:00 AM by Saurabh Tyagi

    Can not create consumer

    Saurabh Tyagi Newbie

      Hello Guys,

       

      I need to create multiple clients on one queue/topic so that each client recive its own individual message and not all recive one.

      I created a code jusing JMS and i am facing sam error (all clients are getting same message).

       

      I got a sample code for hornetq core api. using that i can send message to the queue but not when i try to connect as consumer its states an error

       

      HornetQException[errorCode=100 message=Queue topic/HungamaTopic does not exist]
      

       

      The code i am using is as follows.

       

      public void createPublisher()
                {
      
                          HashMap map = new HashMap();
                          map.put("host", "192.168.4.43");
                          map.put("port", 5445);
      
                          ServerLocator serverLocator = null;
                          ClientSessionFactory factory = null;
                          ClientSession session = null;
                          TransportConfiguration configuration = new TransportConfiguration(NettyConnectorFactory.class.getName(), map);
      
      
                          try {
      
      
                                    serverLocator = HornetQClient.createServerLocatorWithoutHA(configuration);
      
      
                                    factory = serverLocator.createSessionFactory();
                                    session = factory.createSession(true, true);
                                    ClientProducer producer = session.createProducer("topic/HungamaTopic");
                                    System.out.println(producer.getAddress());
                                    ClientMessage message = session.createMessage(true);
                                    message.getBodyBuffer().writeString("Hello");
                                    System.out.println("message = "+ message.getBodyBuffer().readString());
      
                                    producer.send(message);
                                    session.start();
                                    System.out.println(session);
                                    ClientConsumer consumer = session.createConsumer("topic/HungamaTopic");
                                    ClientMessage msgReceived = consumer.receive();
                                    System.out.println("message = "+ msgReceived.getBodyBuffer().readString());
                                    session.close();           
                          } catch (Exception e) {
                                    e.printStackTrace();
      
      
                          }
      
      
                }
      
      

       

      I am not sure whats the issue is. Plz help.

       

       

      The output of above code is as follows

       

      topic/HungamaTopic
      message = Hello
      DelegatingSession [session=ClientSessionImpl [name=67598375-78a2-11e1-9218-f46d04d2e52a, username=null, closed=false, factory = ClientSessionFactoryImpl [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=192-168-4-43], discoveryGroupConfiguration=null], connectorConfig=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=192-168-4-43, backupConfig=null], metaData=()]@5ece2187]
      HornetQException[errorCode=100 message=Queue topic/HungamaTopic does not exist]
                at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:312)
                at org.hornetq.core.client.impl.ClientSessionImpl.internalCreateConsumer(ClientSessionImpl.java:1792)
                at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:478)
                at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:444)
                at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:413)
                at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:418)
                at org.hornetq.core.client.impl.DelegatingSession.createConsumer(DelegatingSession.java:232)
                at com.hungama.esme.jms.HornetqJmsService.createPublisher(HornetqJmsService.java:63)
                at com.hungama.esme.jms.HornetqJmsService.main(HornetqJmsService.java:32)