[jboss-user] [Beginners Corner] - Re: how to create new user for durable topic subscriber lik

sudasudheer do-not-reply at jboss.com
Wed Apr 16 02:51:22 EDT 2008


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 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4144384#4144384

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4144384



More information about the jboss-user mailing list