Configuring MDB (on Glassfish) to listen to a shared topic subscription

821 views Asked by At

What I am looking for is the exact activation configuration property name in order to configure a Message Driven Bean to accept messages from a JMS Topic in Shared subscription mode

@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationLookup",propertyValue = "java:app/jms/testT1"),
    @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Topic"),
    //the below property is not working in GlassFish (4.1) - just to convey the idea
    @ActivationConfigProperty(propertyName = "sharedSubscription",propertyValue = "TRUE") 
})

//edited

Please note: the intention is to be able to use MDBs (against a shared topic for load balancing purposes) in a JavaEE application which can be scaled out horizonatally. This question is not related to a clustered setup, hence use of useSharedSubscriptionInClusteredContainer (in Open MQ) is not applicable

1

There are 1 answers

6
Mike On

If I understand you correctly, you don't need to do this. The point of having multiple consumers allowed on a single subscription was to work around a Java SE limitation, which is not an issue in Java EE:

http://www.oracle.com/technetwork/articles/java/jms2messaging-1954190.html

In Java EE, you just need to create your MDB to subscribe to a topic, then configure the bean pool to have multiple MDBs:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-ejb-jar PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN" "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd">
<glassfish-ejb-jar>
  <enterprise-beans>
    <ejb>
      <ejb-name>MyPooledMDB</ejb-name>
      <bean-pool>
          <max-pool-size>5</max-pool-size>
          <resize-quantity>1</resize-quantity>
          <steady-pool-size>1</steady-pool-size>
      </bean-pool>
    </ejb>
  </enterprise-beans>
</glassfish-ejb-jar>

For more information, see the Oracle GlassFish docs: https://docs.oracle.com/cd/E18930_01/html/821-2418/beait.html

(note that steady-pool-size === "Initial and Minimum Pool Size")