The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: Glassfish mbean for controlling MDB

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is not answered. Helpful answers available: 0. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 8 - Last Post: Feb 4, 2009 9:28 PM by: sppugazh
sppugazh

Posts: 5
Glassfish mbean for controlling MDB
Posted: Jan 9, 2009 3:07 AM
 
  Click to reply to this thread Reply

Hi,

Is there any mbean interface with the functionality like controlling the MDB. My requirement is like the MDB consumes a queue but at times i might need to stop the MDB. Is there any other provision in glassfish to achieve this functionality.I found one document related to oc4j which has a mbean to control the mbean.

mareks

Posts: 25
Re: Glassfish mbean for controlling MDB
Posted: Jan 9, 2009 7:37 AM   in response to: sppugazh
 
  Click to reply to this thread Reply

"stop the mdb" -> if there are no messages in a queue it listens to, mdb is not "running". flushing (removing messages so mdb's can't pick them up) the queue is possible through JMX.

sppugazh

Posts: 5
Re: Glassfish mbean for controlling MDB
Posted: Jan 11, 2009 11:22 PM   in response to: mareks
 
  Click to reply to this thread Reply

Hi Mareks,

Flushing the queue will lead to data loss. I just need to control the mdb from reading the queue. While the mdb is stopped the users will still be putting messages to the queue.so i should not stop the queue from receiving the messages.Is there any other way to control the mdb. I am new to MBean strategy ,so please provide me all the feasible ways to control the ejb from mbean.

With regards,
Pugazh sp

chalava

Posts: 44
Re: Glassfish mbean for controlling MDB
Posted: Jan 12, 2009 7:37 AM   in response to: sppugazh
Helpful
  Click to reply to this thread Reply

You can't stop MDB to consume messages.But you can stop Queue's.If queue is stoped MDB can't consume msg from Queue.

You can control your queue's by controlling by below commnad.

imqcmd pause dst -n MyQueue -t q -pst PRODUCERS|CONSUMERS|ALL
imqcmd resume dst -n MyQueue -t q

you will find above coomand in below location:
Go to : C:\<GLASSFISH_HOME>\imq\bin

Message was edited by: chalava

mareks

Posts: 25
Re: Glassfish mbean for controlling MDB
Posted: Jan 12, 2009 12:10 PM   in response to: chalava
 
  Click to reply to this thread Reply

...and as flushing the queue, pausing/resuming is also possible through JMX.

/mareks

sppugazh

Posts: 5
Re: Glassfish mbean for controlling MDB
Posted: Jan 13, 2009 12:49 AM   in response to: mareks
 
  Click to reply to this thread Reply

Hi,

Is there a way to stop the queue programatically and also to purge the messages in the queue programatically.If this is achievable please give some code snippets to achieve this.

With regards,
Pugazh sp

mareks

Posts: 25
Re: Glassfish mbean for controlling MDB
Posted: Jan 13, 2009 7:36 AM   in response to: sppugazh
Helpful
  Click to reply to this thread Reply

/*create JMXServiceURL object. JMX url can be retrieved by "imqcmd list jmx" command*/
JMXServiceURL url = new JMXServiceURL(".....mq jmx url.....");

/*create JMXConnector object, where environment is a String[] array containing username and password used to access MessageQueue server JMX*/
JMXConnector jmxc = JMXConnectorFactory.connect(url, environment);

/*create MBeanServerConnection and ObjectName for Your queue/topic*/
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
ObjectName destMgrConfigName = MQObjectName.createDestinationConfig(DestinationType.QUEUE, "yourQueueName");
String [] signature = null;
Object [] params = null;

/*this is where You invoke actual method. here "purge" is used. same thing goes for "pause" and other available*/
mbsc.invoke(destMgrConfigName, "purge", params, signature);
jmxc.close();


More on this:

http://docs.sun.com/app/docs/doc/820-6766?l=en&q=Sun+Java+System+Message+Queue+4.3

/mareks

sppugazh

Posts: 5
Re: Glassfish mbean for controlling MDB
Posted: Jan 22, 2009 9:35 PM   in response to: sppugazh
 
  Click to reply to this thread Reply

Thanks for all your support

sppugazh

Posts: 5
Re: Glassfish mbean for controlling MDB
Posted: Feb 4, 2009 9:28 PM   in response to: sppugazh
 
  Click to reply to this thread Reply

As Mareks suggested i tried the same. But it ended up throwing objectnot found exceptions. Is there any link which details in working with the mbean in controlling the resources like queue.

Thanks,
Pugazh




 XML java.net RSS