by reading through the purchased documentation and this forum, finally I successfully set up a MDB on durable subscription. I wrote this mini-howto. Hope, it is helpful to other.
The Jboss server I used is jboss 3.2.3
1. First your ejb-jar.xml should state that this MDB needs a durable subscription.
<!-- notice here, the subscruption is durable subscription -->
2. configure the jboss.xml and jbossmq-state.xml.
The jbossmq-state.xml is located under $JBOSS/server/default/conf.
The jboss.xml is the jboss.xml distributed together with your ejb-jar.xml file.
The jboss.xml looks like this
<!-- uncomment the following if this MDB is listen on a remote topic
You jbossmq-state.xml should look like this
(if you can not view the xml structure correctly, view the page source ).
<!-- other unrelevant information is omitted -->
<Ro le name="subscriber">
The jboss uses client-id and subscription-name/subscription-id to index the durable subscription.
The client-id is always associated with a client(A user). You have two ways to specify the client-id.
You can specify the client-id ethier by the <mdb-client-id> tag in the jboss.xml or by associate a client-id
with user in the jbossmq-state.xml file. But you must not specify them in both locations. Here the first approach
is used. Therefore I only add the user share/share (without client-id)
to the jbossmq-state.xml file. I also add share as a memeber of subscriber.
When JMS client tries to retrieve connection from connection factory, JMS client needs
to supply username/password. Then the connection factory will use its security mechanism(JAAS here)
to authorize the JMS client. Therefore if the
security domain used by connection factory has the proper user/password/role information,
you do not need to add it here in the jbossmq-state.xml file. Otherwise, you need to
add them to jbossmq-state.xml (This idea is not tested!!!). This is Resource authentication. Resource
authentication is a different concept than application user authentication.
You do not need to add anything to the . They will be generated by jboss automatically.
Of course, you can manually add it to the jbossmq-state.xml. It will look like this
<!-- user information is omitted here -->
3. configure the security for the topic.
In the step 2, I state that the share user is in the group subscriber. Therefore I need to make sure
the share user has the permission to read from topic and to create durable subscription.
Here is my topic mbean definition inside of the
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</ depends>
<depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</ depends>
<attri bute name="SecurityConf">
<!-- I grant subscriber role a create rule so
that the share can create durable subscription -->
<ro le name="subscriber" read="true" write="false" create="true"/>
<ro le name="guest" read="true" write="true" create="false"/>
4. deploy the MDB.
After you deploy the MDB, look at the $JBOSS/server/default/conf/jbossmq-state.xml. Notice that the some durable
subscription configuration is added to the file automatically.
5. verify the durability.
a. undeploy the MDB.
b. send some message to the topic.
c. inspect the topic mbean through the jmx-console. From the mbean view, you can find out the count attribute.
This attributes indicates how many messages in this topic is not delivered yet, and how many durable/non-durable
subscription is associated with the topic.