2 Replies Latest reply on Jan 6, 2005 10:05 AM by jpace

    Deploying topics via JMX vs. jboss-service.xml

    jpace

      I am using the default configuration with JBoss 3.2.6. I can deploy a topic using the following XML:

      <mbean code="org.jboss.mq.server.jmx.Topic" name="jboss.mq.destination:service=Topic,name=SampleTopic">
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
       <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
       <attribute name="SecurityConf">
       <security>
       <role name="durpublisher" read="true" write="true" create="true"/>
       </security>
       </attribute>
      </mbean>

      and then I can create a Durable Topic Subscription using the following code:
      InitialContext iniCtx = new InitialContext();
      TopicConnectionFactory tcf =
       (TopicConnectionFactory) iniCtx.lookup("ConnectionFactory");
      TopicConnection conn = tcf.createTopicConnection("john", "needle");
      Topic topic = (Topic) iniCtx.lookup( "topic/SampleTopic" );
      TopicSession session =
       conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
      conn.start();
      TopicSubscriber recv =
       session.createDurableSubscriber(topic, "SampleSubscriber");

      However, if I instead create the topic at runtime, via the JMX Console, I get an exception. I use the createTopic method in the DestinationManager MBean. After the topic has been created, I set the SecurityManager and SecurityConf attributes in the MBean. I set SecurityManager to:
      jboss.mq:service=SecurityManager

      and I set the SecurityConf attribute to:
      <security><role name="durpublisher" read="true" write="true" create="true"/></security>

      When I try to subscribe to the topic using the code above, I get the following exception:
      15:37:46,781 INFO [STDOUT] javax.jms.JMSSecurityException: Connection not authorized to do durable subscription on topic: SampleTopic
      15:37:46,781 INFO [STDOUT] at org.jboss.mq.security.ServerSecurityInterceptor.subscribe(ServerSecurityInterceptor.java:135)
      15:37:46,782 INFO [STDOUT] at org.jboss.mq.server.TracingInterceptor.subscribe(TracingInterceptor.java:816)
      15:37:46,782 INFO [STDOUT] at org.jboss.mq.server.JMSServerInvoker.subscribe(JMSServerInvoker.java:297)
      15:37:46,782 INFO [STDOUT] at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java:160)
      15:37:46,798 INFO [STDOUT] at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:358)
      15:37:46,798 INFO [STDOUT] at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:377)
      15:37:46,799 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
      15:37:46,799 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)

      Any idea what steps I'm missing when I create the topic via JMX instead of deploying it via XML?

        • 1. Re: Deploying topics via JMX vs. jboss-service.xml

          Using setSecurityConf after the destination has started is ignored.
          You would need to do it directly on the security manager.

          • 2. Re: Deploying topics via JMX vs. jboss-service.xml
            jpace

            Yes, that solved the issue. For completeness, let me summarize:

            To create a topic at runtime, via JMX:

            1. Call the createTopic operation on the DestinationManager MBean. For the example I gave in the original posting, the call would be createTopic("SampleTopic", "topic/SampleTopic").

            2. Call the addDestination operation on the SecurityManager MBean. For the example I gave in the original posting, the first parameter would be "SampleTopic", and the second parameter would be a org.w3c.dom.Element with a value of

            <security><role name="durpublisher" read="true" write="true" create="true"/></security>