0

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

Abhishek
  • 1,175
  • 1
  • 11
  • 21

1 Answers1

0

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")

Mike
  • 4,852
  • 1
  • 29
  • 48
  • Thanks for your inputs Mike. you're correct. I was slightly off-mark with regards to the requirement (I have edited it). The goal is not to depend on app server specific clustering. Rather, treat the each JavaEE container process as a stateless (and horizontally) scalable entity. In case my load increases, one should be able to fire additional instances and have the MDB 'share' the load e.g. if 2 messages are sent to the topic, and I have the same MDB on 2 nodes, each should receive 1 message each (shared). Idea is very similar to consumer groups in Kafka – Abhishek Jan 06 '17 at 15:00
  • It should be possible to achieve this using a Java SE container by creating a shared consumer object and handling the concurrency part using custom code (something which MDBs provide for free). But again, my point was to be able to use MDBs to achieve this – Abhishek Jan 06 '17 at 15:08
  • I think the key distinction here is between subscribers and consumers. A shared subscription allows you to have multiple consumers on a single subscription, but you can still have multiple subscribers on a topic. A pool of MDBs on a single server, or on multiple servers, will (I think) be implemented as different subscribers, which will give you the effect you want anyway. (multiple MDBs each getting messages from the same topic). – Mike Jan 06 '17 at 15:17
  • Yes Mike. Subscriptions and consumers are different JMS concepts. But the subscription mode (in this case 'shared') is something which a consumer (the client) decides - it's not configured on the JMS broker. So, in the case with a remote broker and individual JVM processes (MDBs), it should be the responsibility of the MDB provider to clearly specify it's 'subscription mode' – Abhishek Jan 12 '17 at 15:26
  • I tried the following setup (1) Two Payara standalone instances configured as a cluster (http://blog.payara.fish/creating-a-simple-cluster-with-payara-server) - important thing to note is that EJB related clustering has not been activated on purpose since my whole intent is to model a microservice-style setup (stateless instances which can be scaled up easily) (2) remote OpenMQ with a topic (3) a WAR with a MDB on both the instances – Abhishek Jan 12 '17 at 15:26
  • If a message is sent to the topic (via a dedicated producer app), the MDBs in both the Payara instances recieve that message. This is actually expected (but not desired in this case) since an explicit 'shared' subscription has not been created on the broker (by the MDB) as opposed to a Java SE client, which can do so using the standdard JMS 2.0 API - https://docs.oracle.com/javaee/7/api/javax/jms/JMSContext.html#createSharedConsumer-javax.jms.Topic-java.lang.String-java.lang.String- to do the same Hope I am not missing anything... – Abhishek Jan 12 '17 at 15:26