0 Replies Latest reply on Jul 5, 2013 9:12 AM by erasmo2 marciano2

    How I can create a Topic JMS

    erasmo2 marciano2 Master

      Hi

      I have following this guide

       

      http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/JMS_Examples-A_Pub_Sub_Example.html

       

      I Compile my source Java Correctly

      But I don't understant where I define URL on JBOSS for connect

       

      {

              InitialContext iniCtx = new InitialContext();

              Object tmp = iniCtx.lookup("ConnectionFactory");

              TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;

              conn = tcf.createTopicConnection();

              topic = (Topic) iniCtx.lookup("topic/testTopic");

              iniCtx.composeName("java.naming.provider.url", "remote://localhost:4447");

              session = conn.createTopicSession(false,

                                                TopicSession.AUTO_ACKNOWLEDGE);

              conn.start();

          }

       

      In another example (JMS QUEUE) I define Url Jboss connect so:

       

      // Set up all the default values

          private static final String DEFAULT_MESSAGE = "Hello, World inviato 100 volte!";

          private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";

          private static final String DEFAULT_DESTINATION = "jms/queue/test";

      //    private static final String DEFAULT_DESTINATION = "jms/topic/test";

          private static final String DEFAULT_MESSAGE_COUNT = "100";

          private static final String DEFAULT_USERNAME = "quickstartUser";

          private static final String DEFAULT_PASSWORD = "quickstartPassword";

          private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";

          private static final String PROVIDER_URL = "remote://localhost:4447";

       

          public static void main(String[] args) throws Exception {

       

              ConnectionFactory connectionFactory = null;

              Connection connection = null;

              Session session = null;

              MessageProducer producer = null;

              MessageConsumer consumer = null;

              Destination destination = null;

              TextMessage message = null;

              Context context = null;

       

              try {

                  // Set up the context for the JNDI lookup

                  final Properties env = new Properties();

                  env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

                  env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));

                  env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));

                  env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));

                  context = new InitialContext(env);

       

       

       

       

       

      Can I help me?