• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMX in JBoss

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I want to write a piece of code that gets notified whenever any Topic/Queue is added in JBoss App Server at runtime .

What I have known so far is that , there is one org.jboss.mq.server.jmx.DestinationManager MBean in JBoss ,you can create and destroy queues and topics at runtime through the DestinationManager MBean. DestinationManager provides createQueue and createTopic operations for this also . How would I proceed ?
If I want to connect to DestinationManager MBean what are the properties required for setting up the InitialContext ? also what will be the parameter for InitialContext.lookUp(parametreName) ?

I some one has something like this please suggest , it would be great if you have sample codes or docs .
Regards,
Ayan
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't connect to the MBean directly from JNDI. Instead you connect to the MBean Server Connector. This is pretty well documented in the JBoss site, but it is something like this...



Once you have the connector, you can get the MBean by it's object name, like so...



Of course, you have to know the particular domain names for the MBean that you want. There may also be a way to query by type -- not sure.

Hope this helps,
Henry

[EDIT: disabled smilies]
[ September 08, 2006: Message edited by: Henry Wong ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our JBoss forum...
 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Henry .Your answer solved my query.I want share my piece of code
that I have written for test purpose .

package jmx;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;

import javax.management.MBeanServerConnection;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.naming.Context;
import javax.naming.InitialContext;

public class FinalConnectAndInvoke
{
public static void main(String[] args)
{
/**
* You can't connect to the MBean directly from JNDI.
* Instead you connect to the MBean Server Connector.
*/
InitialContext ctx = null;
try
{

System.out.println(" *** Fetching JNDI Connector *** ");
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,"org.jboss.naming rg.jnp.interfaces");

ctx = new InitialContext(env);
MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
String objectName = "jboss.mq:service=DestinationManager";

// Just Testing whether a method can be invoked successfully
server.invoke(new ObjectName(objectName), "stop",null,null);
System.out.println("stop Method Invoked Successfully ");

// Invoking createQueue method to add a queue named NewQueueByAyan by invoking the
// createQueue method

Object[] param = new Object[1];
param[0]="NewQueueByAyan";
String[] signature = new String[1];
signature[0]= "java.lang.String";
server.invoke(new ObjectName(objectName), "createQueue",param,signature);

System.out.println("createQueue Method Invoked Successfully ");
}
catch(Exception e)
{
System.out.println("Exception Occurred ...");
e.printStackTrace();
}
}
}



Regards,
Ayan
 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I want to do another thing . I want to know the all queues and topics
names programmatically . I have gone throgh the JBoss JMX console and studied
the MBeans like DestinationManager..etc . But I am not getting any methods that returna all the queue/topic name .Any clue ?

If I want to write my own MBean that will be return all the queue and topic names ,what will be the procedure ?

Regards ,
Ayan Dutta
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic