0 Replies Latest reply on Mar 25, 2006 3:18 AM by gioelante

    Jms Messages to Topic don't arrive

    gioelante

      Hi,
      I use Jboss 4.0.3 SP1 as Jms provider and java 5 to send to a queue a text message and a object message and everything works. Unfortunately when I try to send to a topic the problem is that no error running the standalone java application appears but no message were sent, in fact using jboss web-console I can't view no message in the topic (testTopic). How can I do? Can you help me I don't known what it's wrong or if there is a jboss configuration file to write. Here is the jndi.properties included in the java project classpath I wrote:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=jnp://localhost:1099


      Here is the code (I found it in a book):
      import java.io.IOException;
      import java.io.InputStream;
      import java.io.OutputStream;
      import java.io.PrintWriter;
      import java.io.StringWriter;
      import javax.servlet.*;
      import javax.servlet.http.*;
      import javax.jms.*;
      import javax.naming.*;


      public class TopicSupplier
      {TopicConnectionFactory topicConnectionFactory;
      TopicConnection topicConnection;
      TopicSession topicSession;
      Topic topic;
      TopicPublisher topicPublisher;


      public TopicSupplier()
      {
      super();
      // TODO Stub di costruttore generato automaticamente
      }
      public static void createATopicAndPublishOrder()
      {InitialContext context;
      try
      {
      context = new InitialContext();
      TopicSupplier topicSupplier;
      try
      {
      topicSupplier = new TopicSupplier(context);
      topicSupplier.send();
      topicSupplier.close();
      context.close();
      } catch (JMSException e)
      {
      e.printStackTrace();
      }

      } catch (NamingException e )
      {
      e.printStackTrace();
      }



      }



      public TopicSupplier(InitialContext context) throws NamingException, JMSException

      {String jmsFactoryName="TopicConnectionFactory";

      topicConnectionFactory=(TopicConnectionFactory) context.lookup(jmsFactoryName);
      topicConnection=topicConnectionFactory.createTopicConnection();
      topicSession=topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      String topicName="topic/testTopic";
      try
      {//determina se già esiste
      topic=(Topic)context.lookup(topicName);

      }catch (NamingException namingException){
      //se non esiste la crea
      topic=topicSession.createTopic(topicName);
      //colega la topic al nome
      context.bind(topicName,topic);

      }
      topicPublisher=topicSession.createPublisher(topic);



      }

      public void send() throws JMSException
      { TextMessage sendingMessage=topicSession.createTextMessage();
      topicConnection.start();
      sendingMessage.setText("Prova");
      topicPublisher.publish(sendingMessage);
      }

      public void close()
      {
      try
      {
      topicPublisher.close();
      topicSession.close();
      topicConnection.close();
      } catch (JMSException e)
      {

      e.printStackTrace();
      }

      }

      public static void main(String[] args)
      {

      createATopicAndPublishOrder();

      }

      }



      Thank you in advance for your attention, Leda