Author: chirino Date: Fri Sep 1 08:30:50 2006 New Revision: 439353 URL: http://svn.apache.org/viewvc?rev=439353&view=rev Log: Latest export from confluence Modified: incubator/activemq/site/weblogic-integration.html Modified: incubator/activemq/site/weblogic-integration.html URL: http://svn.apache.org/viewvc/incubator/activemq/site/weblogic-integration.html?rev=439353&r1=439352&r2=439353&view=diff ============================================================================== --- incubator/activemq/site/weblogic-integration.html (original) +++ incubator/activemq/site/weblogic-integration.html Fri Sep 1 08:30:50 2006 @@ -365,36 +365,7 @@

ActiveMQ as a WebLogic Application

-

The easiest type of WebLogic application to configure with all the needed ActiveMQ libraries and configuration and not much else is a web application. The JARs go in WEB-INF/lib/ and config files typically in WEB-INF/. The only necessary configuration for the web application itself is to install a listener that will start and stop ActiveMQ when the web application is started and stopped.

- -

The easiest way to do this is to a use the commonly available Spring listeners, which start a Spring context, which can point ActiveMQ to an XBean configuration file, which starts ActiveMQ. A little roundabout, but it works well in practice with very little configuration.

- -

J2EE WEB-INF/web.xml

-
-
<?xml version="1.0" encoding="UTF-8"?>
-
-<web-app version="2.4"
-         xmlns="http://java.sun.com/xml/ns/j2ee"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
-    <listener>
-        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
-    </listener>
-</web-app>
-
-

Spring WEB-INF/applicationContext.xml

-
-
<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-<beans>
-    <bean id="brokerService" class="org.apache.activemq.xbean.BrokerFactoryBean">
-        <property name="config" value="classpath:activemq-config.xml"/>
-    </bean>
-</beans>
-
-

Again, the web.xml listener starts Spring and reads the Spring META-INF/applicationContext.xml file (the default location used by the ContextLoaderListener), and the applicationContext.xml indicates that the ActiveMQ configuration file should be read from the class path with the name activemq-config.xml. That file could be placed in WEB-INF/classes or in a directory on the file system that is added to the WebLogic class path (for ease of editing).

- -

With this approach, the normal WebLogic deployment tools, admin console, etc. can be used to deploy, start, stop, and restart ActiveMQ (packaged into a web application WAR). Additionally, a simple web page included in the WAR will be available whenever ActiveMQ is running, so a simple HTTP request can determine whether the ActiveMQ module has been started.

+

The easiest type of WebLogic application to configure with all the needed ActiveMQ libraries and configuration and not much else is a web application. The JARs go in WEB-INF/lib/ and config files typically in WEB-INF/. The only necessary configuration for the web application itself is to install a listener that will start and stop ActiveMQ when the web application is started and stopped. There are also a couple optional classes that can be used to integrate ActiveMQ with WebLogic's management and security systems. Additionally, in this example, a simple web page included in the WAR will be available whenever ActiveMQ is running, so a simple HTTP request can determine whether the ActiveMQ module has been started.

Management Options

@@ -413,13 +384,13 @@ -

Security Options

+

The sample below includes an optional class that lets ActiveMQ hook into the WebLogic runtime MBeanServer. This means ActiveMQ MBeans will appear alongside WebLogic MBeans (and even JVM MBeans if they are enabled). This means management clients will access ActiveMQ MBeans through the normal WebLogic listen port (e.g. 7001) rather than using a dedicated JMX port, though IIOP must be enabled for this to work. However, note that this is optional, and you can skip this class and use one of the other approaches (JVM or embedded MBeanServer) to expose the ActiveMQ MBeans.

-

ActiveMQ has optional authentication and authorization plugins, which are based on JAAS. Fortunately, WebLogic provides a JAAS LoginModule that performs the authentication against the default WebLogic security realm, and returns the appropriate principals for authorization. Some wiring is required to link these together, but the bottom line is that ActiveMQ can use the WebLogic security realm to process a login and then you can configure the WebLogic principals (users and/or groups) that should be allowed to connect.

+

Security Options

-

You may choose to use authentication only, in which case any user with a valid WebLogic login can access ActiveMQ. You may also add authorization to that, so that the ActiveMQ broker as a whole or individual destinations limit the users which can interact with them.

+

ActiveMQ has optional authentication and authorization plugins, which are based on JAAS. Fortunately, WebLogic provides a JAAS LoginModule that performs the authentication against the default WebLogic security realm, and returns the appropriate principals for authorization. Unfortunately, by default, ActiveMQ cannot authorize access to specific users within the security realm based on WebLogic principals, meaning either there's no security or a login is required but any user with a valid login has full access to ActiveMQ. However, with custom security classes like the ones shown below, ActiveMQ can use the WebLogic security realm to process a login and then you can configure the WebLogic principals (users and/or groups) that should be allowed to perform read/write/create/remove actions on a per-broker or per-destination basis.

-

For purposes of this example, we have only implemented an authorization approach that allows any member of a single specific WebLogic group to access all resources in ActiveMQ. Between the authorization plugin provided here and the default one provided with ActiveMQ, you should have the foundation to enhance this if more feature-rich authorization is required.

+

You may choose to use authentication only, in which case any user with a valid WebLogic login can access ActiveMQ, and no custom code is necessary. You may also add authorization to that using some custom code, to apply specific security constraints to specific users or destinations. For purposes of this example, we have only implemented an authorization approach that allows any member of a single specific WebLogic group to access all resources in ActiveMQ. Between the authorization plugin provided here and the default one provided with ActiveMQ, you should have the foundation to enhance this if more feature-rich authorization is required.

ActiveMQ Integration Architecture

@@ -447,7 +418,64 @@ -

Code and Configuration Files

+

Building the ActiveMQ to WebLogic Integration WAR

+ +

This section discusses the code, libraries, and configuration files necessary to build the ActiveMQ web application that will be deployed in WebLogic Express.

+ +
Starting and Stopping ActiveMQ
+ +

ActiveMQ needs to start when the web application is deployed or started, and stop when the web application is stopped or undeployed. The easiest way to do this is to a use the commonly available Spring listeners, which start a Spring context, which can point ActiveMQ to an XBean configuration file, which starts ActiveMQ. A little roundabout, but it works well in practice with very little configuration.

+ +

J2EE WEB-INF/web.xml

+
+
<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.4"
+         xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
+    <listener>
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    </listener>
+</web-app>
+
+

Spring WEB-INF/applicationContext.xml

+
+
<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<beans>
+    <bean id="brokerService" class="org.apache.activemq.xbean.BrokerFactoryBean">
+        <property name="config" value="classpath:activemq-config.xml"/>
+    </bean>
+</beans>
+
+

Again, the web.xml listener starts Spring and reads the Spring META-INF/applicationContext.xml file (the default location used by the ContextLoaderListener), and the applicationContext.xml indicates that the ActiveMQ configuration file should be read from the class path with the name activemq-config.xml. That file could be placed in WEB-INF/classes or in a directory on the file system that is added to the WebLogic class path (for ease of editing).

+ +

With this approach, the normal WebLogic deployment tools, admin console, etc. can be used to deploy, start, stop, and restart ActiveMQ (packaged into a web application WAR).

+ +
Required Libraries
+ +

ActiveMQ required a number of JARs which should be included in the web application WEB-INF/lib directory.

+ +

This list was generated for ActiveMQ 4.0.1:

+ + + +

Additionally, to build the custom security plugins, the WebLogic server/lib/weblogic.jar is presently required at compile time.

+ +

Of these, Derby could be omitted if ActiveMQ was configured to not use a database for persistence or to use a separate database for persistence. The WebLogic JAR is needed only at build time (it's provided by the server at runtime). Spring could be omitted if a different strategy was used to start and stop ActiveMQ when the web app was started or stopped (a little custom code could replace this dependency). The rest are probably unavoidable, unless ActiveMQ changes its dependencies in a future version.

+ +
Code and Configuration Files

TODO: show and discuss code for:

-

ActiveMQ Web Application

- -

TODO: List the JARs that need to go into the web app, and repeat or refer to the web.xml and applicationContext.xml listed above

-

Installation Procedure

This procedure makes the following assumptions:

@@ -536,8 +560,8 @@