yes ,, I think I am doing the mistake while using it actually I am using it fom 
simple pojo class.....



  | public class Sender_Count 
  | {
  |     
  | 
  |     
  | 
  | 
  |     public static QueueConnectionFactory    factory         = null;
  |     public static QueueConnection                   connection      = null;
  |     public static QueueSession                              session         
= null;
  |     public static QueueSender                               sender          
= null;
  |     public static Context                                   ctx             
        = null;
  |     public static javax.jms.Queue                   queue           = null;
  |     public static TextMessage                               message         
= null;
  |     public static ConnectionMetaData                metadata        = null;
  |     public static Queue                                             obj     
                = null;
  |     
  |     //public static JMSQueue  queue  = null;
  |     
  |     
  |     public static void main(String[] args)
  |     {
  | 
  |             /*
  |              * Hashtable env = new Hashtable(); 
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContext"); 
env.put(Context.PROVIDER_URL,"jnp://localhost:1099"); 
env.put(Context.URL_PKG_PREFIXES,"jboss.naming:org.jnp.interfaces");
  |              */  
  |             
  |             
  |             
  |             Hashtable env = new Hashtable();
  | 
  |             env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
  |             env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
  |             env.put(Context.URL_PKG_PREFIXES, 
"jboss.naming:org.jnp.interfaces");
  | 
  |             
  |             
  |             try
  |             {
  |                     ctx = new InitialContext(env);
  |                     factory = (QueueConnectionFactory) 
ctx.lookup("UIL2ConnectionFactory");
  |                     connection = factory.createQueueConnection();
  |                     session = connection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
  |                     queue = (javax.jms.Queue) ctx.lookup("queue/C");
  |                     sender = session.createSender(queue);
  |                     connection.start();
  |                     message = session.createTextMessage();
  |                     message.setText("Bajirao_Mastani");
  |                     sender.send(message);
  |                     
  |     
  |                     
  |                     
  | 
  |     String domain = "jboss.mq.destination";
  |     String service = "service=Queue";
  |     String name = "name=queue/C";
  |             
  |     String stringObjectName = domain + ":" + service + "," + name;
  |             
  |     MBeanServer server = MBeanServerLocator.locateJBoss();
  |             
  |     try{
  |             ObjectName queueObjectName = 
ObjectName.getInstance(stringObjectName);
  |             
  |             org.jboss.mq.server.jmx.QueueMBean queueMBean = 
  |                     (org.jboss.mq.server.jmx.QueueMBean) 
MBeanServerInvocationHandler.newProxyInstance(
  |                                     server,
  |                                     queueObjectName,
  |                                     
org.jboss.mq.server.jmx.QueueMBean.class,
  |                                     false
  |                             );
  |             
  |             logger.info("queue depth: " + queueMBean.getQueueDepth());
  |             
  |     }catch (Exception e){
  |             logger.info("cannot get depth of the queue: " + 
e.getMessage(),e);
  |     }               
  |                     
  |                 
  |             }
  |             catch (NamingException e)
  |             {
  |                     e.printStackTrace();
  |             }
  |             catch (JMSException se)
  |             {
  |                     se.printStackTrace();
  |             }
  |             catch (ClassCastException ce)
  |             {
  |                     ce.printStackTrace();
  |             }
  | 
  |     }
  | }
  | 
  | 


I think i  am doing something wrong by calling it in above fashion from simple 
pojo class...Iam in trouble because of that locateJboss() so  help me.

Thanks :)



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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031870
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to