3 Replies Latest reply: Jun 6, 2011 3:56 AM by 866216 RSS

    OpenMQ not receiving messages by producer

    866216
      Hi,

      I'm new to JMS, i'm just trying to make other people's piece of code work and i've got a problem with messages not arriving to OpenMQ.

      I've isolated the problem in the following example:

      import javax.jms.*;

      public class JMSTest {
      public static void main(String [] args) throws javax.jms.JMSException {
      // factoria
      com.sun.messaging.TopicConnectionFactory conFactory = new com.sun.messaging.TopicConnectionFactory();
      conFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqBrokerHostPort, "7676");
      conFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqBrokerHostName, "localhost");
      conFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqReconnectEnabled, "true");
      conFactory.setProperty(com.sun.messaging.ConnectionConfiguration.imqReconnectAttempts, "-1");

      // Creacion de conexion
      TopicConnection theConnection = conFactory.createTopicConnection();
      theConnection.start();

      // Sesion
      TopicSession theSession = theConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

      // Crear Topic
      Topic myTopic = theSession.createTopic("TESTTopic");

      // Productor de mensajes y envio de estos
      MessageProducer myMsgProducer = theSession.createPublisher(myTopic);
      while (true) {
      TextMessage myMsg = theSession.createTextMessage();
      myMsg.setText("aslkdjflaskjd");
      myMsgProducer.send(myMsg);
      }
      }
      }

      I run the imqbrokerd and then run the above small example. The broker correctly reports the session, topic and producer creation, but the messages aren't received (If i open imqadmin and watch the created topic's properties the message count stands 0).

      Any ideas?

      Imqbrokerd logs:

      [02/jun/2011:14:44:23 CEST] Received JMQRBufferSize -100
      [02/jun/2011:14:44:23 CEST] [B1065]: Aceptando: guest@127.0.0.1:47755->jms:54383. Total: servicio=1 agente=2
      [02/jun/2011:14:44:23 CEST] Created new session 4343774962400028928 on connection 4343774962400004608
      [02/jun/2011:14:44:23 CEST] attempting to set Message Count Limit to 100000 for destination TESTTopic [Tema]
      [02/jun/2011:14:44:23 CEST] attempting to set Message Bytes Limit to 10485760K for destination TESTTopic [Tema]
      [02/jun/2011:14:44:23 CEST] attempting to set Message Size Limit to 10240K for destination TESTTopic [Tema]
      [02/jun/2011:14:44:23 CEST] [B1132]: Creando destino automáticamente TESTTopic [Tema]
      [02/jun/2011:14:44:23 CEST] Creating new Producer 4343774962400037632 on T:TESTTopic for connection 4343774962400004608
        • 1. Re: OpenMQ not receiving messages by producer
          ak
          This is expected if you don't have any subscriber or durable subscriber on the Topic. Please see JMS specification section 6.3 Durable Subscription
          • 2. Re: OpenMQ not receiving messages by producer
            Nigeldeakin-Oracle
            Just to add to what ak correctly says:

            You're sending messages to a topic, but there are no subscribers on that topic. This means the broker throws away the message. This is a basic characteristic of topics, and what distinguishes topics from queues. If you create a subscriber on that topic and then send messages to the topic, you will see that the subscriber gets the messages, so long as the subscriber exists at the time when the message is sent. A subscription can be either durable or non-durable. A non-durable subscription only exists as long as the consuming program is actually running and connected to the JMS provider, whereas a durable subscription can exist even if the program that created it isn't running. In the latter case messages get saved in the JMS provider until the consuming program connects to the subscription and actively consumes messages from it.

            There's a short description which may help in the JMS tutorial at
            http://download.oracle.com/javaee/6/tutorial/doc/bncdx.html#bnced

            Nigel
            • 3. Re: OpenMQ not receiving messages by producer
              866216
              Thank you for your answers... I've got a consumer running too, but i thought the problem had to be with the producer.

              Thanks to your comments i know now that my problem is with my consumer, not the producer, so i'm marking this as answered. I'll post questions about the consumer in another thread if i can't figure out why it doesn't work.