How to create a MDB 3.0 singleton ?

EJB 3 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”)

If you are running JBoss 4/5/6 you can configure this at EJB container level by changing 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.