Home JBoss howto EJB How to create a MDB 3.0 singleton ?
30 | 07 | 2010
JBoss 5 AS Book
"JBoss AS 5 development" reviews
Please share your feedback/review with other readers!
Banner
Dashboard
Advertise with Us
Banner
RSS Feed
Java EE 1.6 resources
Login
Sign here for the NewsLetter.



JBoss admin resources
Banner
Java EE 1.6 resources
JBoss howto

How to avoid the 50 seconds start up limit in Eclipse ?

JBoss recipe of the day ...
Read More

How can you solve deployment errors caused by large war/jar/ear files ?

jboss recipe of the day ...
Read More

How do you configure your .war to be deployed after your EJB ?

jboss recipe of the day ...
Read More
How to create a MDB 3.0 singleton ?
Written by Mark S.   

JBoss recipe of the day

 

 

EJB3 uses the resource adapter.  When using the resource adapter, you need to constrain the number of Sessions:  so you set the minimum for the sessions.  This will essentially give you a singleton. 

 

You can set the maxSession in your bean with an annotation by adding :

@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1")

 

You can add this by default in the server/$/deploy/ejb3-interceptors-aop.xml file 


      <annotation expr="!class(@org.jboss.annotation.ejb.DefaultActivationSpecs)">
         @org.jboss.annotation.ejb.DefaultActivationSpecs (value={@~ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1")})
      </annotation>


This will set the default for all message driven beans.

Will it work in a cluster too ?
 

No , if you want a clustered singleton MDB you need to deploy your mdb in

deploy-hasingleton

or create your own clustered singleton deployment.
 


JBoss.org Search
Custom Search
Comments
Search
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."