1 2 Previous Next 15 Replies Latest reply on Apr 18, 2008 11:28 AM by Arvind Aggarwal

    how  to create new user for durable topic subscriber like jo

    sudheer Newbie

      I am new to JOBSS, I started working on jboss 4.2.2 version, I am working on JMS API, I examples i saw one example for durable subscriber, I am able to execute sample using user name : john and password : needle, so I want to know how to create new user for durable topic subscriber like john.


      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");
      props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
      props.setProperty("java.naming.provider.url", "localhost:1099");
      Context ic = new InitialContext(props);
      Object tmp = ic.lookup("ConnectionFactory");
      TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
      conn = tcf.createTopicConnection("john2","needle"); // here I want to pass some another user details, how can I do this ?
      topic = (Topic) ic.lookup("topic/example");

      Appricate early replies.
      Sudheer…

        • 1. Re: how  to create new user for durable topic subscriber
          sudheer Newbie

           

          "sudasudheer" wrote:
          I am new to JOBSS, I started working on jboss 4.2.2 version, I am working on JMS API, I examples i saw one example for durable subscriber, I am able to execute sample using user name : john and password : needle, so I want to know how to create new user for durable topic subscriber like john.


          Properties props = new Properties();
          props.setProperty("java.naming.factory.initial",
          "org.jnp.interfaces.NamingContextFactory");
          props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
          props.setProperty("java.naming.provider.url", "localhost:1099");
          Context ic = new InitialContext(props);
          Object tmp = ic.lookup("ConnectionFactory");
          TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
          conn = tcf.createTopicConnection("john2","needle"); // here I want to pass some another user details, how can I do this ?
          topic = (Topic) ic.lookup("topic/example");

          Appricate early replies.
          Sudheer…


          • 2. Re: how  to create new user for durable topic subscriber lik
            Jeroen Wenting Newbie

            no need to first crosspost your question and next quote yourself if you don't get a reply inside of 5 minutes.
            That's not going to make you very popular...

            • 3. Re: how  to create new user for durable topic subscriber lik
              sudheer Newbie

              i tried to edit the subject, can you help me to my problem ?

              • 4. Re: how  to create new user for durable topic subscriber lik
                Peter Johnson Master

                I am not sure which JMS example you are using. The only use of the user/password of john/needle that I could find was for some of the JMS tests. It appears that for those specific tests, a database login module is used, so the account information is stored in the database. To add new accounts, you would have to update the database. In the JMS source, the files src/etc/server/default/*-persistence-service.xml contains the SQL statements that populate the database with several accounts. You can follow those to create new accounts (and don't forget to add the accounts to the roles!)

                • 5. Re: how  to create new user for durable topic subscriber lik
                  sudheer Newbie

                  Thanks for your response peter johnson.

                  I Tried to solve using your post, but I am not able to execute the fallowing program using different user name and password (user name : jmsuser password: durable).

                  I found one file with name "null-persistence-service.xml", under "C:\jboss-4.2.2.GA\server\default\conf",
                  I have to add new user details in any xml file?
                  where and how to give sql commands ?

                  Can you give me the STEPS to create a new user(for example user name : jmsuser password: durable) ,

                  Can you please execute the fallowing program using username : jmsuser and password : durable

                  I am able to execute the fallowing program by
                  1) Giving john and needle as user name and password and
                  2) Entry in "C:\jboss-4.2.2.GA\server\default\deploy\jms\jbossmq-destinations-service.xml" file as fallows.


                  jbossmq-destinations-service.xml
                  ----------------------------------

                  <mbean code="org.jboss.mq.server.jmx.Topic"
                  name="jboss.mq.destination:service=Topic,name=example">
                  <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                  <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
                  <attribute name="SecurityConf">
                  <security>
                  <role name="durpublisher" read="true" write="true" create="true"/>
                  </security>
                  </attribute>
                  </mbean>
                  
                  




                  // source code

                  package pubsub;

                  import java.util.Enumeration;
                  import java.util.Properties;

                  import javax.jms.JMSException;
                  import javax.jms.Message;
                  import javax.jms.MessageListener;
                  import javax.jms.Topic;
                  import javax.jms.TopicConnection;
                  import javax.jms.TopicConnectionFactory;
                  import javax.jms.TopicPublisher;
                  import javax.jms.TopicSubscriber;
                  import javax.jms.TopicSession;
                  import javax.jms.TextMessage;
                  import javax.naming.Context;
                  import javax.naming.InitialContext;
                  import javax.naming.NamingException;


                  public class DurableTopicRecvClient {
                  TopicConnection conn = null;

                  TopicSession session = null;

                  Topic topic = null;

                  public void setupPubSub() throws JMSException, NamingException {

                  Properties props = new Properties();
                  props.setProperty("java.naming.factory.initial",
                  "org.jnp.interfaces.NamingContextFactory");
                  props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
                  props.setProperty("java.naming.provider.url", "localhost:1099");
                  Context ic = new InitialContext(props);
                  Object tmp = ic.lookup("ConnectionFactory");
                  TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;

                  //conn = tcf.createTopicConnection("john","needle");

                  conn = tcf.createTopicConnection("jmsuser","durable"); // I want to pass these details , how can I do this ?


                  topic = (Topic) ic.lookup("topic/example");
                  session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
                  conn.start();
                  }

                  public void recvSync() throws JMSException, NamingException {
                  System.out.println("Begin recvSync");
                  // Set up the pub/sub connection, session
                  setupPubSub();
                  // Wait up to 8 seconds for the message
                  TopicSubscriber recv = session.createDurableSubscriber(topic,
                  "This is DurableSubscriber ");

                  Message msg = recv.receive(17000);

                  if (msg == null) {
                  System.out.println("Timed out waiting for msg");
                  } else {
                  System.out.println("DurableTopicRecvClient.recv, msgt=" + msg);
                  }

                  }

                  public void stop() throws JMSException {
                  conn.stop();
                  session.close();
                  conn.close();
                  }

                  public static void main(String args[]) throws Exception {
                  System.out.println("Begin DurableTopicRecvClient, now="
                  + System.currentTimeMillis());
                  DurableTopicRecvClient client = new DurableTopicRecvClient();

                  client.recvSync();

                  client.stop();
                  System.out.println("End DurableTopicRecvClient");
                  System.exit(0);
                  }
                  }

                  Sudheer

                  • 6. Re: how  to create new user for durable topic subscriber lik
                    Arvind Aggarwal Newbie

                    For creating a new user for durable subscriber I had to make some changes in 'hsqldb-jdbc-state-service.xml' (default/deplo/jms). If you have not made any changes for the db to maintian state then you can add a new user by adding below mentioned statements.

                    POPULATE.TABLES.15 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('scott', 'tiger')
                    POPULATE.TABLES.16 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('scott','guest')
                    POPULATE.TABLES.17 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('subscriber','scott')
                    POPULATE.TABLES.18 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('publisher','scott')
                    POPULATE.TABLES.19 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('durpublisher','scott'

                    You can substitue scott/tiger with your username and pwd. Atleast this does works for me.

                    -Arvind

                    • 7. Re: how  to create new user for durable topic subscriber lik
                      Peter Johnson Master

                      Oops, I thought you were using JBoss Messaging, but you are using JBossMQ.

                      I will assume you are using the Hypersonic database (that is the default). Look at server/default/deploy/jms/hsqldb-jdbc-state-service.xml, you will see these lines:

                      POPULATE.TABLES.03 = INSERT INTO JMS_USERS (USERID, PASSWD, CLIENTID) VALUES ('john', 'needle', 'DurableSubscriberExample')
                       POPULATE.TABLES.04 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('nobody', 'nobody')
                       POPULATE.TABLES.05 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('dynsub', 'dynsub')
                       POPULATE.TABLES.06 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('guest','guest')
                       POPULATE.TABLES.07 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('j2ee','guest')
                       POPULATE.TABLES.08 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('john','guest')
                       POPULATE.TABLES.09 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('subscriber','john')
                       POPULATE.TABLES.10 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('publisher','john')
                       POPULATE.TABLES.11 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('publisher','dynsub')
                       POPULATE.TABLES.12 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('durpublisher','john')


                      Note the line that creates the john/needle account, and the line that adds john to the durpublisher group. Add the following lines:

                      POPULATE.TABLES.15 = INSERT INTO JMS_USERS (USERID, PASSWD) VALUES ('jmsuser', 'durable')
                       POPULATE.TABLES.16 = INSERT INTO JMS_ROLES (ROLEID, USERID) VALUES ('durpublisher','jmsuser')


                      Then delete the directory server/default/data. Fianlly start the app server.

                      • 8. Re: how  to create new user for durable topic subscriber lik
                        sudheer Newbie

                        Thanks for your response peter Johnson and Arvind. I am able to create new user now...
                        I am doing some research, I am about start a new project, Can I have differences between JBossMQ and Jboss Messaging.

                        Please tell me the changes in above program if i want to use SAME PROGRAM for JBoss Messaging?

                        • 9. Re: how  to create new user for durable topic subscriber lik
                          Peter Johnson Master

                          If you are starting a new project, you should be using JBoss Messaging. The documentation should outline some of the features and differences between it an JBossMQ. You will have to download and install JBoss Messaging if you are using JBossAS 4.2.2. (For JBossAS 5.0, JBoss Messaging is already provided.)

                          Looking at JBoss 5.0.0.Beta4, you can make the same changes by editing the file server/default/deploy/messaging/hsqldb-persistence-service.xml.

                          Finally, if you plan on moving your app to production, you will need to use a database other than Hypersonic.

                          • 10. Re: how  to create new user for durable topic subscriber lik
                            Jeroen Wenting Newbie

                            JBoss messaging in JBoss 5 beta 4 is fundamentally broken due to missing classes from the core JBoss messaging libraries (known problem, see JIRA for JBM).
                            You'd need to transplant a new standalone JBM version into JBAS 5b4 and hope for the best.

                            • 11. Re: how  to create new user for durable topic subscriber lik
                              sudheer Newbie

                              You means to say that above program I can use for JBoss Messaging also ,Right ?

                              If yes Please tell me where I have to give the entries for
                              1) ConnectionFactory (my factory name "MyConnectionFactory")
                              2) Queue and topic

                              And necessay changes if any, to execute the above program.

                              I am using jboss-4.2.2.GA Application Server and jboss-messaging-1.4.0.SP3 (I am not using jboss5.x because it is a beta version)

                              • 12. Re: how  to create new user for durable topic subscriber lik
                                sudheer Newbie

                                ou means to say that above program I can use for JBoss Messaging also ,Right ?

                                If yes Please tell me where I have to give the entries for
                                1) ConnectionFactory (my factory name "MyConnectionFactory")
                                2) Queue and topic And necessay changes if any.

                                to execute the above program.

                                I am using jboss-4.2.2.GA Application Server and jboss-messaging-1.4.0.SP3 (I am not using jboss5.x because it is a beta version)

                                • 13. Re: how  to create new user for durable topic subscriber lik
                                  Peter Johnson Master

                                  The JMS client code is the same, whether you use JBossMQ or JBoss Messaging. So the code you have should work without any changes.

                                  It looks like you defined your own durable topic. You will have to change its declaration. Just follow the examples provided in the server/default/deploy/messaging/destinations-service.xml file.

                                  • 14. Re: how  to create new user for durable topic subscriber lik
                                    Peter Johnson Master

                                    Oh, messaging works on 5.0 beta4, as long as you include the necessary jars in your classpath. [I have the list and will make it available for reasonable price. This is a limited time offer, so call now! All major credit cards accepted! ;-) (Sorry, its Friday...)]

                                    1 2 Previous Next