-
1. Re: Messaging configuration in AS 7
jason.greene Jul 11, 2011 12:30 PM (in response to smurfs)Hi Andrew,
Unfortunately we won't have MDB support in Final. We deproritized anything non-web profile once we found out that due to recent certification requirements, we have to do extra work to make sure that there is no way that a user can consume the feature in whatever our certified configuration (and distribution) is. It will be one of the first features we have in early 7.1 releases, however if there is enough demand we may be able to backport something in a 7.0.x update.
In the meantime you could use a traditional JMS listener inside of an ejb singleton deployment. Unless you would rather wait.
-
2. Re: Messaging configuration in AS 7
smurfs Jul 11, 2011 12:53 PM (in response to jason.greene)Hi Jason,
Thank you for the prompt reply. I'll do as suggested to get my code running and will refactor once 7.1 is out.
Regards, Andrew
-
3. Re: Messaging configuration in AS 7
tomjenkinson Jul 13, 2011 4:30 AM (in response to jason.greene)Is there an example of best practice for the route you suggested? Lets say I deployed a dummy EJB so that I could get an MDB:
public interface MyFakeMDB extends javax.jms.MessageListener {
}
@Stateless
@Singleton
public class MyFakeMDBImpl MyFakeMDB {
public void onMessage(Message message) {
}
}
Assuming this is totally a fake EJB and I just want it to have MDB like behavior, where should I put the JMS code to bind my message listener to the queue.
I don't mean what code do I need to write:
MessageConsumer mc = ((ConnectionFactory) new InitialContent().lookup("ConnectionFactory")).createConnection().createSession().createMessageConsumer((Destination)new InitialContext().lookup("foo"));
mc.setMessageListener(this);
What I mean is, where should this code go? I guess the constructor, but with AS7, will the EJB constructor only be called when someone accesses my the EJB through an interface, or is an instance of my EJB always created as soon as I deploy my ear/war?
<quick grep of the internet/>
Actually, I just checked online and can see that I can put this in the constructor,and put the following annotation as well:
javax.ejb.Startup
Which leads to the following:
public interface MyFakeMDB extends javax.jms.MessageListener {
}
@Stateless
@Singleton
@Startup
public class MyFakeMDBImpl implements MyFakeMDB {
@Inject
Context ic;
MessageConsumer mc;
public MyFakeMDBImpl() {
ConnectionFactory cf = (ConnectionFactory) ic.lookup("ConnectionFactory");
Connection c = cf.createConnection();
Session s = c.createSession();
Destination d = (Destination)ic.lookup("foo");
mc = s.createMessageConsumer(d);
mc.setMessageListener(this);
}
public void onMessage(Message message) {
}
}
Does that look like the best way to do this? I suppose the only issue with this would be if I wanted JTA? In which case I would end up writing quite a bit more code to manage "XAConnectionFactory" code?
-
4. Re: Messaging configuration in AS 7
wolfc Jul 13, 2011 5:26 AM (in response to tomjenkinson)I would say try out branch https://github.com/wolfc/jboss-as/tree/AS7-579. It contains the preliminary code for JMS MDB support.