Rishi k [
http://community.jboss.org/people/rishi321] created the discussion
"Unable to validate user HornetQ"
To view the discussion, visit:
http://community.jboss.org/message/599262#599262
--------------------------------------------------------------
Hi guys,
I am using jboss AS 6 Final on ubuntu with hornetQ
I have created a new Queue on the server named Message Buffer Queue using the admin
panel.
I get the following error:
Unable to validate user: guest for check type CONSUME for address
jms.queue.MessageBufferQueue
Here are my files:
package org.jboss.example;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.UUID;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.QueueBrowser;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
public class TestClass {
ConnectionFactory Hconnection=null;
Queue q=null;
Connection Hconn=null;
Context lContext=null;
MessageConsumer messageConsumer=null;
MessageProducer messageProducer=null;
javax.jms.Session session=null;
/**
* @param args
*/
public void sendMessagetoJMS(String sender,String receiver,String Message,String
smsc,String Credit,String userid,long ctime,String savenumber)
{
int count=0;
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
ht.put(Context.PROVIDER_URL, "127.0.0.1");
ht.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
try{
lContext = new InitialContext(ht);
Hconnection = (ConnectionFactory)
lContext.lookup("ConnectionFactory");
q = (Queue) lContext.lookup("queue/MessageBufferQueue");
Hconn = (Connection)
Hconnection.createConnection("guest","guest");
session = Hconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
messageProducer = session.createProducer(q);
/*
* Insert into Database
*/
UUID id=UUID.randomUUID();
Hconn.start();
textmsg msg = new textmsg();
msg.setReciever(receiver);
msg.setSender(sender);
msg.setText(Message);
msg.setSmsc(smsc);
msg.setCredit(Credit);
msg.setUserid(userid);
msg.setCtime(ctime);
msg.setId(id.toString());
ObjectMessage message = session.createObjectMessage();
message.setObject(msg);
messageProducer.send(message);
System.out.println("Message sent ");
Hconn.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public int getQueueSize()
{
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
ht.put(Context.PROVIDER_URL, "127.0.0.1");
ht.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
InitialContext ctx;
int numMsgs = 0;
try {
ctx = new InitialContext(ht);
QueueConnectionFactory connFactory = (QueueConnectionFactory)
ctx.lookup("ConnectionFactory");
Queue queue = (Queue)
ctx.lookup("queue/MessageBufferQueue");
QueueConnection queueConn =
connFactory.createQueueConnection("guest","guest");
QueueSession queueSession =
queueConn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
QueueBrowser queueBrowser = queueSession.createBrowser(queue);
queueConn.start();
Enumeration e = queueBrowser.getEnumeration();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.SSSSSS");;
String s=null;
while (e.hasMoreElements()) {
Message message = (Message) e.nextElement();
s = df.format(message.getJMSTimestamp());
System.out.println("=================1===================Timestamp it
got to the queue"+s);
numMsgs++;
}
queueConn.close();
} catch (Exception e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
}
return numMsgs;
}
public static void main(String[] args) {
int i = 0;
TestClass tc = new TestClass();
System.out.println(tc.getQueueSize());
tc.sendMessagetoJMS("jk", "gv", "Hey there",
"somesmsc", "34", "thedon", 234233634,
"2423487");
System.out.println(tc.getQueueSize());
}
}
My
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/599262#599262]
Start a new discussion in JBoss Messaging Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]