[jboss-user] [EJB 3.0] - Stopping an MDB from Listening to a Queue

pbaker01 do-not-reply at jboss.com
Mon Dec 15 22:08:02 EST 2008


I have posted this question on a few different forums... So I apologize again for the cross posting.

Most recent at: JBoss.com -> JBoss User -> JBoss Messaging
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147381
And I have been referred to this forum.

Problem: 
I have a queue and a listener. The listener is configured as a MDB. I want to be able to: 
   o Start/Stop the queue delivery via JMX 
   o Start/Stop the queue delivery programatically 

I have seen several posts that suggest that I should be able to use JMX to "stopDelivery".  When I look at my JMX console page I do not see any reference to my MDB and certanly no references to stopDelivery.  I have deployed the application via Eclipse as  "Exploded".

Environment: 
JBoss: Jboss-5.0.0 GA 
JDK: jdk1.6.0_10 

Below is the code for my MDB: 
import javax.ejb.ActivationConfigProperty;
  | import javax.ejb.MessageDriven;
  | import javax.jms.JMSException;
  | import javax.jms.Message;
  | import javax.jms.MessageListener;
  | import javax.jms.TextMessage;
  | 
  | @MessageDriven(mappedName = "jms/SSMListener", activationConfig = {
  | 		@ActivationConfigProperty(propertyName="messagingType", propertyValue="javax.jms.MessageListener"),
  | 		@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
  | 		@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
  | 		@ActivationConfigProperty(propertyName="destination",propertyValue="queue/SSMQueue") })
  | public class SSMListener implements MessageListener {
  | 
  | 	public void onMessage(Message arg0) {
  | 		// TODO Auto-generated method stub
  | 		TextMessage tm = (TextMessage) arg0;
  | 		try {
  | 			System.out.println("I'm alive - " + tm.getText());
  | 		} catch (JMSException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 	}
  | }	

JBoss.xml
<jboss>
  |  <enterprise-beans>
  |  <message-driven>
  |  <ejb-name>SSMListener</ejb-name>
  |  <local-jndi-name>jms/SSMListener</local-jndi-name>
  |  <destination-jndi-name>queue/SSMQueue</destination-jndi-name>
  |  </message-driven>
  |  </enterprise-beans>
  | </jboss>	

destinations-service.xml 
  <mbean code="org.jboss.mq.server.jmx.Queue"
  | 	 name="jboss.mq.destination:service=Queue,name=SSMQueue">
  |     <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
  |   </mbean>

Here is are two snapshots of my JMX console. 

http://img.picbite.com/2008/12/14/22833fjhhs.png 
http://img.picbite.com/2008/12/14/22835imemm.png 

I don't see any JMX controls for startDelivery or stopDelivery. 
  o What am I doing wrong here? 
  o Do I need to configure the MDB as an mbean? 

For start/stoping programatically I have the following code: 
ObjectName objectName;
  | try {
  |         objectName = new ObjectName(
  |                         "jboss.j2ee:binding=message-driven-bean, jndiName=jms/SSMListener, plugin=invoker,service=EJB");
  |         MBeanServer server = MBeanServerLocator.locateJBoss();
  |         server.invoke(objectName, "stopDelivery", new Object[] {}, null);
  | } catch (MalformedObjectNameException e1) {
  |         // TODO Auto-generated catch block
  |         e1.printStackTrace();
  | } catch (NullPointerException e1) {
  |         // TODO Auto-generated catch block
  |         e1.printStackTrace();
  | } catch (InstanceNotFoundException e) {
  |         // TODO Auto-generated catch block
  |         e.printStackTrace();
  | } catch (MBeanException e) {
  |         // TODO Auto-generated catch block
  |         e.printStackTrace();
  | } catch (ReflectionException e) {
  |         // TODO Auto-generated catch block
  |         e.printStackTrace();
  | }       	

This code generates exception: 
anonymous wrote : 10:55:55,157 ERROR [STDERR] javax.management.InstanceNotFoundException: jboss.j2ee:binding=message-driven-bean, jndiName=jms/SSMListener, plugin=invoker,service=EJB is not registered. 
  | 10:55:55,158 ERROR [STDERR] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:529) 
  | 10:55:55,158 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:662) 
  | 10:55:55,158 ERROR [STDERR] at com.sita.wab.service.SsimService.startLoad(SsimService.java:65) 
  | 10:55:55,158 ERROR [STDERR] at com.sita.wab.ejb.ssim.SsimEjbBean.startLoad(SsimEjbBean.java:32)

I suspect once I get the JMX issue resolved the answer to this problem will be obvious. 

Other than the starting/stopping the queue, everything else works well. 

Any help will be greatly appreciated. 

And again, I apologize again for the cross posting. Hopefully the answer will be found here :)

Paul


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

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



More information about the jboss-user mailing list