Dear all,
I am doing a simple timer example. At least I think I am doing that. Based on a liberal reading and understanding of the public documentation I think I need a Scheduler that can be configured through service.xml. The Scheduler is configured by the XML file but basiccally invokes the method "hit" on "com.test.testMDB" at the specified moments (see attached service.xml).
Then I need a Schedulable. I opt for the MBean approach. The Mbean, for now, implements hit through printing a message to stderr. Thus I implement both "hit" and "onMessage" (see TestMDB.java).
Now, doubts are getting the upperhand. Do I need to configure a queue? Do I need the "onMessage" method? What deployment xml (ejb-jar.xml and jboss.xml) do I need? Is it really as simple as described above?
Thanks for any suggestions!
John-Luc
[service.xml]
true
jboss:type=example,name=schedulable
hit( NOTIFICATION, DATE, REPETITIONS, SCHEDULER_NAME, java.lang.String )
NOW
10000
10
[TestMDB.java]
package com.test;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.ejb.EJBException;
import javax.jms.MessageListener;
import javax.jms.Message;
public class TestMDB implements MessageDrivenBean, MessageListener {
private MessageDrivenContext ctx=null;
public HelloMDB() {}
//--- MessageDrivenBean
public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
this.ctx=ctx;
}
public void ejbCreate() {}
public void ejbRemove() { ctx=null; }
//--- MessageListener
public void onMessage(Message message) {
System.err.println("Bean got message?");
}
public void hit(javax.management.Notification NOTIFICATION,java.util.Date DATE,long REPETITIONS,javax.management.ObjectName SCHEDULER_NAME, java.lang.String str) {
System.err.println("Bean got scheduled event!");
}
} // TestMDB
Hi
Once and for all post this questions in the JMX section because your problem is that the Scheduler has nothing to do with JMS (I can't imagine how you got there).
Have fun - Andy