The message-driven bean class, clientsessionmdb-ejb/src/java/mdb/MessageBean.java, is almost identical to the one in Chapter 17, A Message-Driven Bean Example. However, the @MessageDriven annotation is different, because instead of a queue the bean is using a topic with a durable subscription, and it is also using a message selector. Therefore, the annotation sets the activation config properties messageSelector, subscriptionDurability, clientId, and subscriptionName, as follows:
@MessageDriven(mappedName = "jms/Topic", activationConfig = { @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "NewsType = 'Sports' OR NewsType = 'Opinion'") , @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable") , @ActivationConfigProperty(propertyName = "clientId", propertyValue = "MyID") , @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "MySub") })
For a message-driven bean, the destination is specified with the mappedName element instead of the lookup element.
The JMS resource adapter uses these properties to create a connection factory for the message-driven bean that allows the bean to use a durable subscriber.