[jboss-cvs] JBoss Messaging SVN: r6496 - in trunk: examples/jms and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 20 09:05:27 EDT 2009
Author: jmesnil
Date: 2009-04-20 09:05:27 -0400 (Mon, 20 Apr 2009)
New Revision: 6496
Added:
trunk/examples/jms/management-notifications/
trunk/examples/jms/management-notifications/build.xml
trunk/examples/jms/management-notifications/readme.html
trunk/examples/jms/management-notifications/server0/
trunk/examples/jms/management-notifications/server0/client-jndi.properties
trunk/examples/jms/management-notifications/server0/jbm-configuration.xml
trunk/examples/jms/management-notifications/server0/jbm-jms.xml
trunk/examples/jms/management-notifications/server0/jbm-queues.xml
trunk/examples/jms/management-notifications/server0/jbm-standalone-beans.xml
trunk/examples/jms/management-notifications/server0/jbm-users.xml
trunk/examples/jms/management-notifications/src/
trunk/examples/jms/management-notifications/src/org/
trunk/examples/jms/management-notifications/src/org/jboss/
trunk/examples/jms/management-notifications/src/org/jboss/jms/
trunk/examples/jms/management-notifications/src/org/jboss/jms/example/
trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java
Modified:
trunk/.classpath
trunk/src/main/org/jboss/messaging/jms/JBossTopic.java
Log:
Management Notifications example
* how to configure JBoss Messaging to receive management notifications using JMS messages
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-04-20 13:02:03 UTC (rev 6495)
+++ trunk/.classpath 2009-04-20 13:05:27 UTC (rev 6496)
@@ -40,6 +40,7 @@
<classpathentry kind="src" path="examples/jms/large-message/src"/>
<classpathentry kind="src" path="examples/jms/last-value-queue/src"/>
<classpathentry kind="src" path="examples/jms/management/src"/>
+ <classpathentry kind="src" path="examples/jms/management-notifications/src"/>
<classpathentry kind="src" path="examples/jms/message-counters/src"/>
<classpathentry kind="src" path="examples/jms/message-group/src"/>
<classpathentry kind="src" path="examples/jms/message-priority/src"/>
Property changes on: trunk/examples/jms/management-notifications
___________________________________________________________________
Name: svn:ignore
+ build
logs
Added: trunk/examples/jms/management-notifications/build.xml
===================================================================
--- trunk/examples/jms/management-notifications/build.xml (rev 0)
+++ trunk/examples/jms/management-notifications/build.xml 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+ ]>
+
+<!-- =========================================================================================== -->
+<!-- -->
+<!-- JBoss, Home of Professional Open Source -->
+<!-- Copyright 2005, JBoss Inc., and individual contributors as indicated -->
+<!-- by the @authors tag. See the copyright.txt in the distribution for a -->
+<!-- full listing of individual contributors. -->
+<!-- -->
+<!-- This is free software; you can redistribute it and/or modify it -->
+<!-- under the terms of the GNU Lesser General Public License as -->
+<!-- published by the Free Software Foundation; either version 2.1 of -->
+<!-- the License, or (at your option) any later version. -->
+<!-- -->
+<!-- This software is distributed in the hope that it will be useful, -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -->
+<!-- Lesser General Public License for more details. -->
+<!-- -->
+<!-- You should have received a copy of the GNU Lesser General Public -->
+<!-- License along with this software; if not, write to the Free -->
+<!-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -->
+<!-- 02110-1301 USA, or see the FSF site: http://www.fsf.org. -->
+<!-- -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging Management Notifications Example">
+
+ <import file="../common/build.xml"/>
+
+ <target name="run">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.jms.example.ManagementNotificationExample"/>
+ </antcall>
+ </target>
+
+ <target name="runRemote">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.jms.example.ManagementNotificationExample"/>
+ <param name="jbm.example.runServer" value="false"/>
+ </antcall>
+ </target>
+
+</project>
Added: trunk/examples/jms/management-notifications/readme.html
===================================================================
--- trunk/examples/jms/management-notifications/readme.html (rev 0)
+++ trunk/examples/jms/management-notifications/readme.html 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,193 @@
+<html>
+ <head>
+ <title>JBoss Messaging Management Notification Example</title>
+ <link rel="stylesheet" type="text/css" href="../common/common.css">
+ </head>
+ <body>
+ <h1>Management Notification Example</h1>
+ <p>This example shows how to receive management notifications from JBoss Messaging using JMS Messages.</p>
+ <p>JBoss Messaging servers emit management notifications when events of interest occur (consumers are created or closed,
+ destinations are created or deleted, security authentication fails, etc.).<br />
+ These notifications can be received either by using JMX (see <a href="../jmx/readme.html">JMX example</a>) or by receiving JMS Messages
+ from a well-known destination.</p>
+ <p>This example will setup a JMS MessageListener to receive management notifications. We will also perform normal JMS operations to see the kind
+ of notifications they trigger.</p>
+
+ <h2>Example configuration</h2>
+
+ <p>JBoss Messaging can configured to send JMS messages when management notifications are emitted on the server.</p>
+ <p>By default, the management name is called <code>jbm.notifications</code> but this can be configured in <a href="server0/jbm-configuration.xml">jbm-configuration.xml</a>.
+ For this example, we will set it to <code>example.notifications</code>.</p>
+ <pre>
+ <code><management-notification-address>example.notifications</management-notification-address></code>
+ </pre>
+
+ <p>We will also create a queue corresponding to the example's address to hold notifications</p>
+ <pre>
+ <code><queues>
+ <queue name="example.notifications">
+ <address>example.notifications</address>
+ </queue>
+ </queues></code>
+ </pre>
+ <p>The notification queue requires permission to create/delete temporary queues and consume messages.
+ This is configured in <a href="server0/jbm-queues.xml">jbm-queues.xml</a></p>
+ <pre>
+ <code><!--security for notification queue-->
+ <security match="example.notifications">
+ <permission type="consume" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ </security></code>
+ </pre>
+
+ <h2>Example step-by-step</h2>
+ <p><em>To run the example, simply type <code>ant</code> from this directory</em></p>
+ <ol>
+ <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get its properties from <a href="server0/client-jndi.properties">client-jndi.properties</a></li>
+ <pre>
+ <code>InitialContext initialContext = getContext(0);</code>
+ </pre>
+
+ <li>We look up the JMS queue object from JNDI</li>
+ <pre>
+ <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code>
+ </pre>
+
+ <li>We look up the JMS connection factory object from JNDI</li>
+ <pre>
+ <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
+ </pre>
+
+ <li>We create a JMS connection, a session and a message producer for the example queue</li>
+ <pre>
+ <code>connection = cf.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(queue);</code>
+ </pre>
+
+ <li>We create the JMS management topic. This is a <em>special</em> topic which is not looked up from JNDI but instantiated directly</li>
+ <pre>
+ <code>Topic notificationsTopic = new JBossTopic("example.notifications", "example.notifications");</code>
+ </pre>
+
+ <li>We create a MessageConsumer for the notification topic and set its MessageListener. When a notification is received, we will simply display all the message properties</li>
+ <pre>
+ <code>MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
+ notificationConsumer.setMessageListener(new MessageListener()
+ {
+ public void onMessage(Message notif)
+ {
+ System.out.println("------------------------");
+ System.out.println("Received notification:");
+ try
+ {
+ Enumeration propertyNames = notif.getPropertyNames();
+ while (propertyNames.hasMoreElements())
+ {
+ String propertyName = (String)propertyNames.nextElement();
+ System.out.format(" %s: %s\n", propertyName, notif.getObjectProperty(propertyName));
+ }
+ }
+ catch (JMSException e)
+ {
+ }
+ System.out.println("------------------------");
+ }
+ });</code>
+ </pre>
+
+ <li>We start the connection to receive messages</li>
+ <pre>
+ <code>connection.start();</code>
+ </pre>
+
+ <p><em>Now that a message listener is setup to receive management notifications, we will perform regular JMS operations to
+ see what kind of notifications are triggered</em></p>
+
+ <li>We create a JMS message consumer on the example queue</li>
+ <pre>
+ <code>MessageConsumer consumer = session.createConsumer(queue);</code>
+ </pre>
+
+ <p>This will generate a <code>CONSUMER_CREATED</code> notification:
+ <pre>
+ <code>------------------------
+ Received notification:
+ _JBM_RoutingName: jms.queue.exampleQueue
+ _JBM_Address: jms.queue.exampleQueue
+ ...
+ _JBM_ConsumerCount: 1
+ ...
+ _JBM_NotifType: CONSUMER_CREATED
+ ------------------------</code>
+ </pre>
+ <p>The notification tells us that a consumer was created for the JMS queue <code>exampleQueue</code>. When the notification
+ was emitted, this consumer was the only one for the queue</p>
+
+ <li>We close this consumer</li>
+ <pre>
+ <code>consumer.close();</code>
+ </pre>
+
+ <p>This will generate a <code>CONSUMER_CLOSED</code> notification:
+ <pre>
+ <code>------------------------
+ Received notification:
+ _JBM_RoutingName: jms.queue.exampleQueue
+ _JBM_Address: jms.queue.exampleQueue
+ ...
+ _JBM_ConsumerCount: 0
+ ...
+ _JBM_NotifType: CONSUMER_CLOSED
+ ------------------------</code>
+ </pre>
+ <p>The notification tells us that a consumer was closed for the JMS queue <code>exampleQueue</code>. When the notification
+ was emitted, there were no other consumers on the queue</p>
+
+ <li>As a last example, we will create a connection with invalid user credentials</li>
+ <pre>
+ <code>try
+ {
+ cf.createConnection("not.a.valid.user", "not.a.valid.password");
+ } catch (JMSException e)
+ {
+ }</code>
+ </pre>
+
+ <p>This will generate a <code>SECURITY_AUTHENTICATION_VIOLATION</code> notification:
+ <pre>
+ <code>------------------------
+ Received notification:
+ _JBM_User: not.a.valid.user
+ ...
+ _JBM_NotifType: SECURITY_AUTHENTICATION_VIOLATION
+ ------------------------
+ </code>
+ </pre>
+ <p>The notification tells us that a user named <code>not.a.valid.user</code> failed to authenticate when creating a connection to JBoss Messaging.</p>
+
+ <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+
+ <pre>
+ <code>finally
+ {
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }</code>
+ </pre>
+ </ol>
+
+ <h2>More information</h2>
+
+ <p>Management notification address is configured in the <a href="../../../docs/userguide/en/html/configuration.html#configuration.main">server configuration</a> by changing the <code>management-notification-address</code> parameter.</p>
+
+
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/examples/jms/management-notifications/server0
___________________________________________________________________
Name: svn:ignore
+ data
logs
Added: trunk/examples/jms/management-notifications/server0/client-jndi.properties
===================================================================
--- trunk/examples/jms/management-notifications/server0/client-jndi.properties (rev 0)
+++ trunk/examples/jms/management-notifications/server0/client-jndi.properties 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added: trunk/examples/jms/management-notifications/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-configuration.xml (rev 0)
+++ trunk/examples/jms/management-notifications/server0/jbm-configuration.xml 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,32 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../../../../src/schemas/jbm-configuration.xsd">
+ <configuration>
+
+ <management-notification-address>example.notifications</management-notification-address>
+
+ <!-- create a default queue for the notification -->
+ <queues>
+ <queue name="example.notifications">
+ <address>example.notifications</address>
+ </queue>
+ </queues>
+
+ <connectors>
+ <connector name="netty">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+ </connector>
+ </connectors>
+
+ <!-- Netty standard TCP acceptor -->
+ <acceptors>
+ <acceptor name="netty">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+ </acceptor>
+ </acceptors>
+
+ <!-- Other configs -->
+ <journal-min-files>2</journal-min-files>
+ </configuration>
+
+</deployment>
Added: trunk/examples/jms/management-notifications/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-jms.xml (rev 0)
+++ trunk/examples/jms/management-notifications/server0/jbm-jms.xml 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,19 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty"/>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ <entry name="XAConnectionFactory"/>
+ <entry name="java:/ConnectionFactory"/>
+ <entry name="java:/XAConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="exampleQueue">
+ <entry name="/queue/exampleQueue"/>
+ </queue>
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/management-notifications/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-queues.xml (rev 0)
+++ trunk/examples/jms/management-notifications/server0/jbm-queues.xml 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,29 @@
+<settings xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+ <!--security for example queue-->
+ <security match="jms.queue.exampleQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security>
+
+ <!--security for notification queue-->
+ <security match="example.notifications">
+ <permission type="consume" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ </security>
+
+ <!-- security settings for JMS temporary queue -->
+ <security match="queuetempjms.*">
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security>
+</settings>
Added: trunk/examples/jms/management-notifications/server0/jbm-standalone-beans.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-standalone-beans.xml (rev 0)
+++ trunk/examples/jms/management-notifications/server0/jbm-standalone-beans.xml 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">1099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">1098</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer" class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="JBMSecurityManager"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="MessagingServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: trunk/examples/jms/management-notifications/server0/jbm-users.xml
===================================================================
--- trunk/examples/jms/management-notifications/server0/jbm-users.xml (rev 0)
+++ trunk/examples/jms/management-notifications/server0/jbm-users.xml 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java
===================================================================
--- trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java (rev 0)
+++ trunk/examples/jms/management-notifications/src/org/jboss/jms/example/ManagementNotificationExample.java 2009-04-20 13:05:27 UTC (rev 6496)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.example;
+
+import java.util.Enumeration;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.naming.InitialContext;
+
+import org.jboss.messaging.jms.JBossTopic;
+
+/**
+ * An example that shows how to receive management notifications using JMS messages.
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ */
+public class ManagementNotificationExample extends JMSExample
+{
+ public static void main(String[] args)
+ {
+ new ManagementNotificationExample().run(args);
+ }
+
+ public boolean runExample() throws Exception
+ {
+ Connection connection = null;
+ InitialContext initialContext = null;
+ try
+ {
+ // Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = getContext(0);
+
+ // Step 2. Perfom a lookup on the queue
+ Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
+
+ // Step 3. Perform a lookup on the Connection Factory
+ ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
+
+ // Step 4.Create a JMS connection, a session and a producer for the queue
+ connection = cf.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(queue);
+
+ // Step 5. create the JMS notification topic.
+ // It is a "special" topic and it is not looked up from JNDI but constructed directly
+ Topic notificationsTopic = new JBossTopic("example.notifications", "example.notifications");
+
+ // Step 6. Create a JMS message consumer for the notification topic and set its message listener
+ // It will display all the properties of the JMS Message
+ MessageConsumer notificationConsumer = session.createConsumer(notificationsTopic);
+ notificationConsumer.setMessageListener(new MessageListener()
+ {
+ public void onMessage(Message notif)
+ {
+ System.out.println("------------------------");
+ System.out.println("Received notification:");
+ try
+ {
+ Enumeration propertyNames = notif.getPropertyNames();
+ while (propertyNames.hasMoreElements())
+ {
+ String propertyName = (String)propertyNames.nextElement();
+ System.out.format(" %s: %s\n", propertyName, notif.getObjectProperty(propertyName));
+ }
+ }
+ catch (JMSException e)
+ {
+ }
+ System.out.println("------------------------");
+ }
+ });
+
+ // Step 7. Start the Connection to allow the consumers to receive messages
+ connection.start();
+
+ // Step 8. Create a JMS Message Consumer on the queue
+ MessageConsumer consumer = session.createConsumer(queue);
+
+ // Step 9. Close the consumer
+ consumer.close();
+
+ // Step 10. Try to create a connection with unknown user
+ try
+ {
+ cf.createConnection("not.a.valid.user", "not.a.valid.password");
+ } catch (JMSException e)
+ {
+ }
+
+ // sleep a little bit to be sure to receive the notification for the security
+ // authentication violation before leaving the example
+ Thread.sleep(2000);
+
+ return true;
+ }
+ finally
+ {
+ //Step 11. Be sure to close the resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/jms/JBossTopic.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/JBossTopic.java 2009-04-20 13:02:03 UTC (rev 6495)
+++ trunk/src/main/org/jboss/messaging/jms/JBossTopic.java 2009-04-20 13:05:27 UTC (rev 6496)
@@ -114,7 +114,7 @@
super(JMS_TOPIC_ADDRESS_PREFIX + name, name);
}
- protected JBossTopic(final String address, final String name)
+ public JBossTopic(final String address, final String name)
{
super(address, name);
}
More information about the jboss-cvs-commits
mailing list