From 633c33f224f3196f3f9bd80bd2e418d8143fea06 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Fri, 4 May 2012 15:39:19 +0000 Subject: QPID-3858: Updated branch - merged from trunk r.1333987 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1334037 13f79535-47bb-0310-9956-ffa450edef68 --- java/jca/example/.gitignore | 19 + java/jca/example/README-EXAMPLE.txt | 235 ++++++++++++ java/jca/example/README-GERONIMO.txt | 69 ++++ java/jca/example/README-GLASSFISH.txt | 84 ++++ java/jca/example/README-JBOSS.txt | 107 ++++++ java/jca/example/README-JBOSS7.txt | 116 ++++++ java/jca/example/README.txt | 277 -------------- java/jca/example/build-geronimo-properties.xml | 21 +- java/jca/example/build-glassfish-properties.xml | 135 +++++++ java/jca/example/build-jboss-properties.xml | 7 +- java/jca/example/build-jboss7-properties.xml | 133 +++++++ java/jca/example/build.xml | 25 +- java/jca/example/conf/geronimo-application.xml | 2 +- java/jca/example/conf/geronimo-ra.xml | 40 +- java/jca/example/conf/glassfish-ejb-jar.xml | 70 ++++ java/jca/example/conf/glassfish-resources.xml | 74 ++++ java/jca/example/conf/glassfish-web.xml | 26 ++ java/jca/example/conf/jboss-ejb-client.properties | 12 + java/jca/example/conf/jboss-web.xml | 5 + java/jca/example/conf/log4j.properties | 18 + java/jca/example/conf/qpid-jca-ds.xml | 27 +- java/jca/example/conf/qpid-standalone.xml | 422 +++++++++++++++++++++ java/jca/example/conf/web.xml | 11 + java/jca/example/qpid-jca-example-properties.xml | 15 +- .../example/client/QpidRequestResponseClient.java | 2 +- .../jca/example/ejb/QpidGoodByeListenerBean.java | 2 +- .../jca/example/ejb/QpidGoodByeSubscriberBean.java | 3 +- .../jca/example/ejb/QpidHelloListenerBean.java | 4 +- .../jca/example/ejb/QpidHelloSubscriberBean.java | 5 +- .../qpid/jca/example/ejb/QpidJMSResponderBean.java | 13 +- .../apache/qpid/jca/example/ejb/QpidTestBean.java | 4 +- .../example/web/QpidRequestResponseServlet.java | 283 ++++++++++++++ .../qpid/jca/example/web/QpidTestServlet.java | 47 ++- 33 files changed, 1973 insertions(+), 340 deletions(-) create mode 100644 java/jca/example/README-EXAMPLE.txt create mode 100644 java/jca/example/README-GERONIMO.txt create mode 100644 java/jca/example/README-GLASSFISH.txt create mode 100644 java/jca/example/README-JBOSS.txt create mode 100644 java/jca/example/README-JBOSS7.txt delete mode 100644 java/jca/example/README.txt create mode 100644 java/jca/example/build-glassfish-properties.xml create mode 100644 java/jca/example/build-jboss7-properties.xml create mode 100644 java/jca/example/conf/glassfish-ejb-jar.xml create mode 100644 java/jca/example/conf/glassfish-resources.xml create mode 100644 java/jca/example/conf/glassfish-web.xml create mode 100644 java/jca/example/conf/jboss-ejb-client.properties create mode 100644 java/jca/example/conf/qpid-standalone.xml create mode 100644 java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidRequestResponseServlet.java (limited to 'java/jca/example') diff --git a/java/jca/example/.gitignore b/java/jca/example/.gitignore index 54c810d4a0..624fd61581 100644 --- a/java/jca/example/.gitignore +++ b/java/jca/example/.gitignore @@ -1,3 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + build/* lib/* *.swp diff --git a/java/jca/example/README-EXAMPLE.txt b/java/jca/example/README-EXAMPLE.txt new file mode 100644 index 0000000000..3a2ee0c38e --- /dev/null +++ b/java/jca/example/README-EXAMPLE.txt @@ -0,0 +1,235 @@ +Qpid JCA Example + +Overview +======== +The Qpid JCA example provides a sample JEE application that demonstrates how to +configure, install and run applications using the Qpid JCA adapter for JEE +connectivity and the Apache Qpid C++ Broker. This example code can be used as a +convenient starting point for your own development and deployment +efforts. + +Example Components +=================== +Currently the example application consists of the following components: + +Destinations +============ +Any messaging application relies on destinations (queues or topics ) +in order to produce or consume messages.The Qpid JCA example provides +the following destinations: + + HelloTopic + GoodByeTopic + HelloQueue + GoodByeQueue + QpidRequestQueue + QpidResponseQueue + +Each destination is configured for the respective application server in which +the examples will be run. Generally the example application allows for sending +messages to a Hello. Depending on a configuration option, once +a message is received by the Hello component, the Hello component can also be +sent to a GoodBye component. + +The QpidRequest/Response destinations provide the destinations for the +request/reponse messaging pattern. + + +ConnectionFactories +=================== +Similar to destinations, ConnectionFactories are a core component of both JMS +and JCA. ConnectionFactories provide the necessary starting point to make a +connection, establish a session and produce or consume (or both) messages from +your JMS provider. + +The Qpid JCA example provides three connection factories by default: + + QpidJMSXA + QpidJMS + QpidConnectionFactory + +Each of these ConnectionFactories varies in their capabilities and the context in which +they should be used. By default, the Qpid JCA examples use the QpidJMSXA connection factory +which provides for full XA transaction support. The QpidJMS connection factory provides a +local JMS transaction CF and is currently deprecated, though it has been maintained for +backwards compatibility. The QpidConnectionFactory is a specialized ConnectionFactory designed +to be used outside of a JEE application server. This CF has been provided to support non-managed +clients that want to use the JNDI facilities of JEE. + +The deployment configuration for destinations, and ConnectionFactories varies by JEE platform. +Please see the application server specific documentation for specific instructions. + +EJB 3.x + +There are a six EJB 3.x components provided as part of the example. + + QpidHelloSubscriberBean - MessageDrivenBean (MDB) + QpidGoodByeSubscriberBean - (MDB) + QpidHelloListenerBean - (MDB) + QpidGoodByeListenerBean - (MDB) + QpidJMSResponderBean - (MDB) + QpidTestBean - Stateless Session Bean (SLSB) + +Generally, the name of the EJB component corresponds to the aforementioned destinations +listed above in the consumption of messages. + +QpidTestServlet +A sample EE 2.5 servlet is provided allowing testing from a browser versus a RMI or JMS +based client. + +QpidTestClient +A Java based client allowing for both RMI or JMS access to the sample application. RMI or +JMS access is based on configuration options. + +QpidRequestResponseClient +A Java based client allowing for a request/response application. + +EE EAR archive + An EAR wrapper for the ejb and web components. + +A build.xml file + An ant build.xml file to configure, install and deploy the aforementioned components. + +Requirements +============ +Apache Qpid Broker +To run the sample it is assumed you have an Apache Qpid C++ broker configured and running. +The example code assumes that the broker will run at localhost on port 5672. The broker +address can be modified in the build-properties.xml file. + +Examples +=============== +Using the Qpid JCA examples is the same regardless of preferred JEE application server. +The provided clients and supported options are listed below. + +QpidTestClient +============== +As previously mentioned, the Qpid JCA example provides an RMI/JMS Java client to test +the application. Executing the command + +ant-run client + +will execute the QpidTestClient client with the default options. + +QpidTestClient Options + +client.use.ejb (build.xml) +Setting this value to false will result in the QpidTestClient using JMS to send messages to +the configured destination. +Default:true + +client.message +The text content of the JMS message sent to the configured destination. +Default: Hello Qpid World! + +client.message.count +The number of messages that will be sent to the configured destionation. +Default: 1 + +client.use.topic +Setting this value to true will send messages to HelloTopic versus HelloQueue. +Default:false + +client.say.goodbye +Setting this value to true will cause the listener on the Hello Queue/Topic to send a +message to the GoodBye Queue/Topic +Default:false + + +QpidRequestResponseClient +========================= +Similar to the QpidTestClient, the QpidRequestResponseClient is a Java based application that allows for +sending messages to a destination. The QpidRequestResponseClient also provides the capability for the +application to listen for a response. Executing the command + +ant run-reqresp + +will run the application with the default options. + +QpidRequestResponseClient Options + +QpidTestServlet +=============== +Similar to the QpidTestClient application, the Qpid JCA examples also provides a JEE Servlet to test and run the +application. This Servlet can be used as an alternative, or in conjunction with the Java application. The Servlet +can be reached via the following URL: + +http://:/qpid-jca-web/qpid + +where server-host and server-port are the host and port where you are running your application server. + +QpidTestServlet Options + +The QpidTestServlet options can be configured by appending certain values to the above URL. These values are +listed below and generally correspond, both in name and purpose, to the Java application configuration options. + +message +The text content of the JMS message sent to the configured destination. +Default: Hello World! + +useEJB +Setting this value to true will result in the QpidTestServlet using the QpidTestBean SLSB to +send the message to the configured destination. By default the QpidTestServlet uses JMS. +Default:false + +count +The number of messages that will be sent to the configured destionation. +Default: 1 + +useTopic +Setting this value to true will send messages to HelloTopic versus HelloQueue. +Default:false + +sayGoodBye +Setting this value to true will cause the listener on the Hello Queue/Topic to send a +message to the GoodBye Queue/Topic +Default:false + +useXA +Setting this value to true will cause the QpidTestServlet to do all activity within the +context of an XA transaction. +Default:false + +useTX +Setting this value to true will cause the QpidTestServlet to do all activity within the +context of a JMS transation. +Default:false + + +Note, the useXA and useTX are mutually exclusive. Setting both to true, the QpidTestServlet +will choose XA over a JMS transaction. + +QpidRequestResponseServlet +========================== +Similar to the QpidRequestResponseClient application, the Qpid JCA examples also provides a JEE Servlet +to execute the request/response type messaging pattern. The Servlet can be reached via the following url: + +http://:/qpid-jca-web/qpid-reqresp + +where server-host and server-port are the host and port where you are running your application server. + +QpidRequestResponseServlet Options + +message +The text content of the JMS message sent to the configured destination. +Default: Hello World! + +count +The number of messages that will be sent to the configured destionation. +Default: 1 + +useXA +Setting this value to true will cause the QpidTestServlet to do all activity within the +context of an XA transaction. +Default:false + +Summary +======= +While conceptually simple, the Qpid JCA examples provide a majority of the component types and messaging patterns +you are most likely to use your development efforts. With the Web and EJB components, you can experiment with +various aspects of JCA as well as EE development in general using the Qpid Broker as your messaging provider. +While this documentation highlights the major components and steps needed to take to get the example running, +the possiblities for modifcation are numerous. You are encouraged to experiment with the example as you work +to develop your own messaging applications. + + diff --git a/java/jca/example/README-GERONIMO.txt b/java/jca/example/README-GERONIMO.txt new file mode 100644 index 0000000000..d58d034c79 --- /dev/null +++ b/java/jca/example/README-GERONIMO.txt @@ -0,0 +1,69 @@ +Qpid JCA Example - Apache Geronimo 2.x + +Overview +======== +This document explains the steps required to configure and +deploy the Qpid JCA examples for the Apache Geronimo environment. +General information can be found in the README.txt file. + +The Apache Geronimo environment provides two methods for deploying +JEE application components: the web-based administration console and the +command line based deployment environment. This document only explains +the command line environment. Please see the Apache Geronimo 2.x +documentation for the web-based console. + +Requirements +============ +In order to deploy the Qpid JCA adapter, as well as the example application, +the GERONIMO_HOME environemnt variable must be set. The environment variable +should point to the root of your Apache Geronimo 2.x install directory. + +In order to automatically deploy the Qpid JCA Adapter, the QPID_JCA_HOME +environment variable needs to be set. The environment variable should point +to the directory which contains the Qpid JCA Adapter. If building from the +source tree, by default this can be found at + +QPID_ROOT/java/build/lib + +If installing from RPM or other binary distribution, this can vary by platform. + +Prior to deploying any application component, the Apache Geronimo application +should be started and available for requests. + + +Deploy the Qpid JCA Adapter +============================== +Once the above requirements are satisfied the command + +ant deploy-rar + +will attempt to use the Apache Geronimo deployer to install the Qpid JCA +adapter into the Apache Geronimo environment. Any errors will be reported +back to the client for further examination. Once the above command executes +successfully, the Qpid JCA adapter has been deployed, configured and is ready +for use. + + +Deploy the Qpid JCA Examples +============================ +After the Qpid JCA adapter is deployed, executing the command + +ant deploy-ear + +will attempt to use the Apache Geronimo deploy to install the Qpid JCA +example EAR into the Apache Geronimo environment. Any errors will be reported +back to the client for further examination. Once the above command executes +successfully, the Qpid JCA example application is deployed, configured and ready +for use. + +The build-geronimo-properties.xml file contain Apache Geronimo specific values +and Ant targets that can be used to suit your development requirements. + +The README.txt file in this directory provides the necessary instructions for using the Qpid JCA +adapter and example application. + + + + + + diff --git a/java/jca/example/README-GLASSFISH.txt b/java/jca/example/README-GLASSFISH.txt new file mode 100644 index 0000000000..1b73ba68fd --- /dev/null +++ b/java/jca/example/README-GLASSFISH.txt @@ -0,0 +1,84 @@ +Qpid JCA Example - Glassfish 3.x + +Overview +======== +This document explains the steps required to configure and +deploy the Qpid JCA examples for the Glassfish 3.x environment. + +The Glassfish environment provides two methods for deploying +JEE application components: the web-based administration console +and the asadmin command line utility. This document only explains +the command line utility. Please see the Glassfish 3.x +documentation for the web-based console approach. + +Requirements +============ +In order to deploy the Qpid JCA adapter, as well as the example application, +the GLASSFISH_HOME environemnt variable must be set. The environment variable +should point to the root of your Glassfish installation. + +In order to automatically deploy the Qpid JCA Adapter from the build system, +the QPID_JCA_HOME environment variable needs to be set. +The environment variable should point to the directory which contains the +Qpid JCA Adapter. If building from the source tree, by default this can be found at + +QPID_ROOT/java/build/lib + +If installing from RPM or other binary distribution, this can vary by OS platform. + +The Qpid JCA examples assume the Apache Geronimo application server as the default +target platform. This can be modified in two ways: + +1) Modify the build.xml file and change the target.platform property: + +Example: + + + + +2) Set the target.platform property via the command line: + +Example: + +ant -Dtarget.platform=glassfish + +Note, if you choose the second method, all command line invocations must include +the target.platform variable. For the remainder of this document, we will assume +the second approach. + +Prior to deploying any application component, the Glassfish application server +should be started and available for requests. + + +Deploy and configure the Qpid JCA Adapter +============================== +Once the above requirements are satisfied the command + +ant -Dtarget.platform=glassfish deploy-rar + +will attempt to invoke the asadmin utility to deploy and configure the +Qpid JCA adapter. Once this step completes succesfully the Qpid JCA adapter +is deployed, configured and ready for use. + + +Deploy the Qpid JCA Examples +============================ +After the Qpid JCA adapter is deployed, executing the command + +ant -Dtarget.platform=glassfish deploy-ear + +will attempt to deploy the Qpid JCA example EAR into the Glassfish environment. +Once the above command executes successfully, the Qpid JCA example application +is deployed, configured and ready for use. + +The build-glassfish-properties.xml file contains Glassfish specific configuration options +and Ant targets that can be used to suit your development requirements. Executing + +ant -Dtarget.platform=glassfish -p + +will list the appropriate targets and provide a simple description for each. + +The README.txt file in this directory provides the necessary instructions for using +the Qpid JCA adapter and example application which is consistent across all supported +JEE platforms. + diff --git a/java/jca/example/README-JBOSS.txt b/java/jca/example/README-JBOSS.txt new file mode 100644 index 0000000000..e23b3ba308 --- /dev/null +++ b/java/jca/example/README-JBOSS.txt @@ -0,0 +1,107 @@ +Qpid JCA Example - JBoss EAP 5.x, JBoss 5.x, 6.x + +Overview +======== +This document explains the steps required to configure and +deploy the Qpid JCA examples for both the JBoss EAP 5.x +environment as well as the JBoss 5.x/6.x community edition +(herafter simply referred to as JBoss). General information +can be found in the README.txt file. + +Requirements +============ +In order to deploy the Qpid JCA adapter, as well as the example application, +the JBOSS_HOME environemnt variable must be set. The environment variable +should point to the root of your JBoss installation. + +In order to automatically deploy the Qpid JCA Adapter from the build system, +the QPID_JCA_HOME environment variable needs to be set. +The environment variable should point to the directory which contains the +Qpid JCA Adapter. If building from the source tree, by default this can be found at + +QPID_ROOT/java/build/lib + +If installing from RPM or other binary distribution, this can vary by platform. + +If you do not want to use the build system to deploy the Qpid JCA adapter, you +can simply copy the qpid-ra-0..rar file to the + +JBOSS_HOME/server//deploy + +directory. By default, the example assumes the JBoss 'default' server profile will +be used. This can be modified in the build-jboss-properties.xml file. + +The Qpid JCA examples assume the Apache Geronimo application server as the default +target platform. This can be modified in two ways: + +1) Modify the build.xml file and change the target.platform property: + +Example: + + + + +2) Set the target.platform property via the command line: + +Example: + +ant -Dtarget.platform=jboss + +Note, if you choose the second method, all command line invocations must include +the target.platform. For the remainder of this document, we will assume the second +approach. + +Prior to deploying any application component, the JBoss application server +should be started and available for requests. + + + + +Deploy and configure the Qpid JCA Adapter +============================== +Once the above requirements are satisfied the command + +ant -Dtarget.platform= jboss deploy-rar + +will copy the Qpid JCA adapter to JBoss server deploy directory. + +To configure JCA resources in the JBoss environment, the *-ds.xml configuration file +is used. The command + +ant -Dtarget.platform=jboss deploy-ds + +will accomplish this task using the defaults provided. Any errors will be reported +in the + +JBOSS_HOME/server//log/server.log + +file or on the console. + +Once the above commands execute successfully, the Qpid JCA adapter is deployed, configured +and ready for use. + + +Deploy the Qpid JCA Examples +============================ +After the Qpid JCA adapter is deployed, executing the command + +ant -Dtarget.platform=jboss deploy-ear + +will attempt to deploy the Qpid JCA example EAR into the JBoss environment. +Once the above command executes successfully, the Qpid JCA example application is deployed, +configured and ready for use. + +Note, if making modifications to either the Qpid JCA adapter or *-ds.xml configuration, the +EAR archive will need to be redeployed. This is a JBoss JCA issue and not due to the Qpid JCA +adapter. + +The build-jboss-properties.xml file contains JBoss specific configuration options +and Ant targets that can be used to suit your development requirements. + +The README.txt file in this directory provides the necessary instructions for using the Qpid JCA +adapter and example application which is consistent across all supported JEE platforms. + + + + + diff --git a/java/jca/example/README-JBOSS7.txt b/java/jca/example/README-JBOSS7.txt new file mode 100644 index 0000000000..7a3e0db01a --- /dev/null +++ b/java/jca/example/README-JBOSS7.txt @@ -0,0 +1,116 @@ +Qpid JCA Example - JBoss AS 7 + +Overview +======== +This document explains the steps required to configure and +deploy the Qpid JCA examples for the JBoss AS 7 environment. +General information about the example can be found in the +README-EXAMPLE.txt file. + +Requirements +============ +In order to deploy the Qpid JCA adapter, as well as the example application, +the JBOSS_HOME environemnt variable must be set. The environment variable +should point to the root of your JBoss installation. + +In order to automatically deploy the Qpid JCA Adapter from the build system, +the QPID_JCA_HOME environment variable needs to be set. +The environment variable should point to the directory which contains the +Qpid JCA Adapter. If building from the source tree, by default this can be found at + +QPID_ROOT/java/build/lib + +If installing from RPM or other binary distribution, this can vary by platform. + +If you do not want to use the build system to deploy the Qpid JCA adapter, you +can simply copy the qpid-ra-0..rar file to the + +JBOSS_HOME//deployments + +directory. By default, the example assumes the JBoss 'standalone' server profile will +be used. This can be modified in the build-jboss7-properties.xml file. + +The Qpid JCA examples assume the Apache Geronimo application server as the default +target platform. This can be modified in two ways: + +1) Modify the build.xml file and change the target.platform property: + +Example: + + + + +2) Set the target.platform property via the command line: + +Example: + +ant -Dtarget.platform=jboss7 + +Note, if you choose the second method, all command line invocations must include +the target.platform. For the remainder of this document, we will assume the second +approach. + +As opposed to earlier versions of JBoss AS, JBoss AS 7 uses a different approach for +configuring JCA resources. JBoss AS 7 provides support for different server profiles +each configured through an XML based configuration file. In order to configure the +Qpid JCA adapter for the JBoss AS 7 environment, a complete XML configuration has been +provided in the conf/ directory as conf/qpid-standalone.xml. In order to configure this +file execute the following command: + +ant -Dtarget.platform=jboss7 generate + +The result of this command will produce a file build/gen/qpid-standalone.xml file. To +deploy this file copy the file to: + +JBOSS_HOME/standalone/configuration + +directory. + +Prior to deploying any application component, the JBoss application server +should be started and available for requests. In order to use the qpid-standalone.xml +file generated in the previous step, when starting JBoss AS 7 invoke the following: + +./standalone.sh -c qpid-standalone.xml + + +Note, the above method completely replaces the default messaging provider in JBoss AS 7. +Currently there is no way to have two separate messaging providers deployed within the same +server. It assumed that this will be addressed in a later version of JBoss AS 7. + + +Deploy the Qpid JCA Adapter +============================== +Once the above requirements are satisfied the command + +ant -Dtarget.platform=jboss7 deploy-rar + +will copy the Qpid JCA adapter to JBoss AS 7 server deploy directory. + +Once the above commands execute successfully, the Qpid JCA adapter is deployed, configured +and ready for use. + + +Deploy the Qpid JCA Examples +============================ +After the Qpid JCA adapter is deployed, executing the command + +ant -Dtarget.platform=jboss7 deploy-ear + +will attempt to deploy the Qpid JCA example EAR into the JBoss AS 7 environment. +Once the above command executes successfully, the Qpid JCA example application is +deployed, configured and ready for use. + +Note, currently there is an issue with 'hot-deployment' in the JBoss AS 7 environment. +If you need to re-deploy the EAR file, restarting JBoss AS 7 is required. + +The build-jboss7-properties.xml file contains JBoss AS 7 specific configuration options +and Apache Ant targets that can be used to suit your development requirements. + +The README.txt file in this directory provides the necessary instructions for using the Qpid JCA +adapter and example application which is consistent across all supported JEE platforms. + + + + + + diff --git a/java/jca/example/README.txt b/java/jca/example/README.txt deleted file mode 100644 index d94bbfa7e5..0000000000 --- a/java/jca/example/README.txt +++ /dev/null @@ -1,277 +0,0 @@ -Qpid JCA Example - -Overview -======= -The Qpid JCA example provides a sample JEE application that demonstrates how to -configure, install and run applications using the Qpid JCA adapter for EE -connectivity and the Apache Qpid C++ Broker. This example code can be used as a -convenient starting point for your own development and deployment -efforts. Currently the example is supported on JBoss EAP 5.x, JBoss 6.x and -Apache Geronimo 2.x. - -Example Components -=================== -Currently the example application consists of the following components: - -Destinations and ConnectionFactories - -Any messaging application relies on destinations (queues or topics ) -in order to produce or consume messages.The Qpid JCA example provides -five destinations by default: - - HelloTopic - GoodByeTopic - HelloGoodByeTopic - HelloQueue - GoodByeQueue - QpidResponderQueue - - -Similar to destinations, ConnectionFactories are a core component of both JMS -and JCA. ConnectionFactories provide the necessary starting point to make a connection, -establish a session and produce or consume (or both) messages from your JMS provider. - -The Qpid JCA example provides three connection factories by default: - - QpidJMSXA - QpidJMS - QpidConnectionFactory - -Each of these ConnectionFactories varies in their capabilities and the context in which -they should be used. These concepts will be explained later in this document. - -The deployment configuration for destinations, and ConnectionFactories varies by platform. -In JBossEAP, the configuration mechanism is a *-ds.xml file. Geronimo 2.2.x has the notion -of a deployment plan in the form of a geronimo-ra.xml file. - -The Qpid JCA Example provides both a qpid-jca-ds.xml file as well as a geronimo-ra.xml deployment -plan. Both mechanisms provide a reasonable set of defaults to allow you to deploy the Qpid JCA -adapter in either environment and get up and running quickly. - -EJB 3.x - -There are a six EJB 3.x components provided as part of the example. - - QpidHelloSubscriberBean - MessageDrivenBean (MDB) - QpidGoodByeSubscriberBean - (MDB) - QpidHelloListenerBean - (MDB) - QpidGoodByeListenerBean - (MDB) - QpidJMSResponderBean - (MDB) - QpidTestBean - Stateless Session Bean (SLSB) - -Servlet 2.5 - - QpidTestServlet - -A sample EE 2.5 servlet is provided allowing testing from a browser versus a JNDI -client - -EE EAR archive - An EAR wrapper for the ejb and web components. - - - An RMI client used to excercise the EJB 3.x component. - -Sample *-ds.xml file - A sample *-ds.xml file is provided to create destinations and ManagedConnectionFactories - in the JBoss environment. - -Sample geronimo-ra.xml - A sample geronimo-ra.xml file is provided to create destinations and ManagedConnectionFactories - in the Geronimo environment. This file is semantically equivalent to the JBoss *-ds.xml artifact. - -A build.xml file - An ant build.xml file to configure, install and deploy the aforementioned components. - - -Requirements -============ - -Depending upon your target platform (eg. JBoss EAP or Geronimo) you will need to set either -the JBOSS_HOME or GERONIMO_HOME property. By default, these properties are assumed to be -set from your environment. This can be modified in the build.xml file. - -JBoss EAP 5.x, JBoss 6.x - To use the sample application you will need to have JBoss EAP 5.x or JBoss 6.x running. - -Geronimo 2.x - To use the sample application you will need to have Geronimo 2.x running. - -Apache Qpid Broker - To run the sample it is assumed you have an Apache Qpid C++ broker configured and running. - The example code assumes that the broker will run at localhost on port 5672. This can be - modified within the build.xml file if this does not suit your particular environment. - - -Quickstart -========== -After satifsying the above requirements you are ready to deploy and run the example application. -The steps to deploy and run in the supported application servers are largely the same, however, -if you are targeting JBoss you will either need to modify the property in the example build.xml file - - - - -to be jboss - - - -or set this property via the command line. - -Example: - - ant -Dtarget.platform=jboss - -**Note** -Any time you wish to change platforms, this property needs to be modified and a complete clean -and rebuild needs to be performed. - -Step 1 -- Package, Deploy and configure the Qpid JCA adapter - -The core component of the example is the Qpid JCA adapter. The following lists the steps -for the respective platforms - -**Note** - -Regardless of platform, if you are building the Qpid JCA adapter from source code -you will need to use to package the RAR file via the Ant build system. To do this, from -the example directory execute - - ant deploy-rar - -This task packages the adapter and includes the necessary dependent jar files. - - -JBoss - There are no additional steps to package the adapter for JBoss deployment. Simply copy - the qpid-ra-rar to your JBoss deploy directory. - - To configure the Qpid JCA Adapter in JBoss the *-ds.xml file mechanism is used. A sample - file is provided in the conf directory. - - If the defaults are suitable, you can simply execute - - ant deploy-ds - - While any property can be modified in the qpid-jca-ds.xml file, typically you will want to - change the URL of the broker to which you are trying to connect. Rather than modifying - the qpid-jca-ds.xml file directly you can modify the - - - - line in the build.xml file. This will dynamically insert the broker.url value into the qpid-jca-ds.xml file. - - Once this file is copied to your JBoss deploy directory and you received no exceptions, the adapter is now deployed, configured - and ready for use. - -Geronimo - By default, the Qpid JCA adapter ships with the geronimo-ra.xml deployment plan embedded - in the RAR file. This file is located in the META-INF directory alongside the ra.xml file. - By default the adapter is configured to access a broker located at localhost with the - default port of 5672. The ANONYMOUS security mechanism is also in use. If this is not - desirable, you have two approaches to configure the adapter. - - - 1) Extract the META-INF/ra.xml file from the RAR file, modify and recompress the RAR archive - with the updated contents. - - 2) Use the example build system to package the adapter. The example build.xml file includes - a target - - package-rar - - that can be used to package the RAR file as well as allowing changes to the geronimo-ra.xml - file without having to extract the RAR file by hand. The conf/geronimo-ra.xml file is used - when you use the example build system. - - While any property can be modified in the geronimo-ra.xml file, typically you will want to - change the URL of the broker to which you are trying to connect. Rather than modifying - the geronimo-ra.xml file directly you can modify the - - - - - line in the build.xml file. This will dynamically insert the broker.url value into the geronimo-ra.xml file. - - Once you have made your modifications you can execute - - - ant clean package-rar deploy-rar - - Note, your Geronimo server must be running and your GERONIMO_HOME environment variable must be set. Barring any exceptions, the - adapter is now deployed and ready for use in Geronimo. - - -Step 2 -- Deploy the application component(s). - -As previously mentioned, the adapter comes with a variety of EE components for use in your respective application server. You can choose to deploy -these components individually, or as a single EAR archive. This document assumes that you will use the EAR to deploy and run the example. - -The command to package and deploy the EAR archive is the same across application servers. Executing the following command - -ant deploy-ear - -will, depending upon platform, package the EAR and deploy the archive in your respective environment. Once this step is executed, the example -is ready for use. - - -Step 3 -- Test the Example - -The Qpid JCA example provides an EJB application, as well as a Web application. Both can be used to test/run the example: - -EJB -If you want to use the EJB application to test the example you can execute - - ant run-client - -Running this command will perform a JNDI lookup of the SLSB in either JBoss or Geronimo and send a simple string to the SLSB. The SLSB will receive -this string, construct a JMS message and place this message on a configured queue. The MDB will in turn receive this message and print the contents -to the console. - -The main properties involved in this task are - -server.host -jndi.context - -These vary depending upon which application server you are runnning. These can be modified to suit your environment. Looking at the run-client task you -will see the following: - - - - -This is the JNDI name of the SLSB component and it varies by application server. Typically you do not have to change this. Also, the task supports another property - - - - -You can set this property if you want to modify the message contents being routed through the system. - -Web -The Qpid JCA Example comes with a web application. To access the web component, simply use a browser of your choice and navigate to - -http://:/qpid-jca-web/qpid - -where server-host and server-port are the host and port where you are running your application server. By default this is localhost:8080. Similar to the EJB component, -the web application supports a few options: - - -http://:/qpid-jca-web/qpid?messsage= - -will allow you to customize the message contents that are routed through the system. By default, the Web application posts to a configured queue in the system. If you want to -test XA functionality, or use an alternate approach, you can specify - - -http://:/qpid-jca-web/qpid?useEJB=true - -instead of posting to a queue, the web application will use the local interface of the EJB component to send the message. This is functionally equivalent to running the -RMI client. - - -Summary -======= -While conceptually simple, the Qpid JCA example provides a majority of the component types and messaging patterns you are most likely to use your development efforts. -With the Web and EJB components, you can experiment with various aspects of JCA as well as EE development in general using the Qpid Broker as your messaging provider. -While this documentation highlights the major components and steps needed to take to get the example running, the possiblities for modifcation are numerous. You are -encouraged to experiment with the example as you develop your own messaging applications. - - diff --git a/java/jca/example/build-geronimo-properties.xml b/java/jca/example/build-geronimo-properties.xml index 2251b7a2df..02ecb53134 100644 --- a/java/jca/example/build-geronimo-properties.xml +++ b/java/jca/example/build-geronimo-properties.xml @@ -22,18 +22,31 @@ - + + + + + + + + + + + + + + diff --git a/java/jca/example/build-glassfish-properties.xml b/java/jca/example/build-glassfish-properties.xml new file mode 100644 index 0000000000..94c79be931 --- /dev/null +++ b/java/jca/example/build-glassfish-properties.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jca/example/build-jboss-properties.xml b/java/jca/example/build-jboss-properties.xml index 5fc4053cf8..fd38274630 100644 --- a/java/jca/example/build-jboss-properties.xml +++ b/java/jca/example/build-jboss-properties.xml @@ -21,16 +21,21 @@ + + - + + + + diff --git a/java/jca/example/build-jboss7-properties.xml b/java/jca/example/build-jboss7-properties.xml new file mode 100644 index 0000000000..68ecd8a4f4 --- /dev/null +++ b/java/jca/example/build-jboss7-properties.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jca/example/build.xml b/java/jca/example/build.xml index 2717ce84d7..7a75f9abc6 100644 --- a/java/jca/example/build.xml +++ b/java/jca/example/build.xml @@ -20,7 +20,7 @@ --> - + @@ -72,7 +72,6 @@ - @@ -80,7 +79,8 @@ - + + @@ -91,12 +91,14 @@ + - + + @@ -111,6 +113,9 @@ + + + @@ -119,6 +124,7 @@ + @@ -141,10 +147,13 @@ + + + - + + - @@ -166,8 +175,8 @@ - - + + diff --git a/java/jca/example/conf/geronimo-application.xml b/java/jca/example/conf/geronimo-application.xml index a855e0fae8..384f6b2e75 100644 --- a/java/jca/example/conf/geronimo-application.xml +++ b/java/jca/example/conf/geronimo-application.xml @@ -21,7 +21,7 @@ --> diff --git a/java/jca/example/conf/geronimo-ra.xml b/java/jca/example/conf/geronimo-ra.xml index e3e74ebc62..a7511f647f 100644 --- a/java/jca/example/conf/geronimo-ra.xml +++ b/java/jca/example/conf/geronimo-ra.xml @@ -67,63 +67,73 @@ org.apache.qpid.ra.admin.QpidTopicImpl Dummy - amq.topic + amq.topic org.apache.qpid.ra.admin.QpidTopic org.apache.qpid.ra.admin.QpidTopicImpl - HelloTopic - @qpid.hello.topic.dest.address@ + HelloTopic + @qpid.hello.topic.dest.address@ org.apache.qpid.ra.admin.QpidTopic org.apache.qpid.ra.admin.QpidTopicImpl - GoodByeTopic - @qpid.goodbye.topic.dest.address@ + GoodByeTopic + @qpid.goodbye.topic.dest.address@ + org.apache.qpid.ra.admin.QpidQueue org.apache.qpid.ra.admin.QpidQueueImpl - HelloQueue - @qpid.hello.queue.dest.address@ + HelloQueue + @qpid.hello.queue.dest.address@ org.apache.qpid.ra.admin.QpidQueue org.apache.qpid.ra.admin.QpidQueueImpl - GoodByeQueue - @qpid.goodbye.queue.dest.address@ + GoodByeQueue + @qpid.goodbye.queue.dest.address@ org.apache.qpid.ra.admin.QpidQueue org.apache.qpid.ra.admin.QpidQueueImpl - ResponderQueue - @qpid.responder.queue.dest.address@ + RequestQueue + @qpid.request.queue.dest.address@ + + + + org.apache.qpid.ra.admin.QpidQueue + org.apache.qpid.ra.admin.QpidQueueImpl + + ResponseQueue + @qpid.response.queue.dest.address@ javax.jms.ConnectionFactory org.apache.qpid.ra.admin.QpidConnectionFactoryProxy - QpidConnectionFactory - @broker.url@ + QpidConnectionFactory + @broker.url@ diff --git a/java/jca/example/conf/glassfish-ejb-jar.xml b/java/jca/example/conf/glassfish-ejb-jar.xml new file mode 100644 index 0000000000..e3ea140472 --- /dev/null +++ b/java/jca/example/conf/glassfish-ejb-jar.xml @@ -0,0 +1,70 @@ + + + + + + QpidHelloListenerBean + HelloQueue + + qpid-ra-@rar.ver@ + + + QpidJMSXA + QpidJMSXA + + + + QpidGoodByeListenerBean + GoodByeQueue + + qpid-ra-@rar.ver@ + + + QpidJMSXA + QpidJMSXA + + + + QpidHelloSubscriberBean + HelloTopic + + qpid-ra-@rar.ver@ + + + QpidJMSXA + QpidJMSXA + + + + QpidGoodByeSubscriberBean + GoodByeTopic + + qpid-ra-@rar.ver@ + + + QpidJMSXA + QpidJMSXA + + + + QpidJMSResponderBean + QpidResponderQueue + + qpid-ra-@rar.ver@ + + + QpidJMSXA + QpidJMSXA + + + + QpidTestBean + QpidTestBean + + QpidJMSXA + QpidJMSXA + + + + + diff --git a/java/jca/example/conf/glassfish-resources.xml b/java/jca/example/conf/glassfish-resources.xml new file mode 100644 index 0000000000..9eab4302d5 --- /dev/null +++ b/java/jca/example/conf/glassfish-resources.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jca/example/conf/glassfish-web.xml b/java/jca/example/conf/glassfish-web.xml new file mode 100644 index 0000000000..950ee73d51 --- /dev/null +++ b/java/jca/example/conf/glassfish-web.xml @@ -0,0 +1,26 @@ + + + + + qpid-jca-web + + + QpidTestBean + QpidTestBean + + + + QpidJMSXA + QpidJMSXA + + + HelloQueue + HelloQueue + + + HelloTopic + HelloTopic + + + + diff --git a/java/jca/example/conf/jboss-ejb-client.properties b/java/jca/example/conf/jboss-ejb-client.properties new file mode 100644 index 0000000000..8bf1075c14 --- /dev/null +++ b/java/jca/example/conf/jboss-ejb-client.properties @@ -0,0 +1,12 @@ +endpoint.name=client-endpoint +remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false + +remote.connections=default + +remote.connection.default.host=localhost +remote.connection.default.port = 4447 +remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false + +remote.connection.default.username=wmprice +remote.connection.default.password=72whtu78 + diff --git a/java/jca/example/conf/jboss-web.xml b/java/jca/example/conf/jboss-web.xml index edacf8d418..32a97d1c35 100644 --- a/java/jca/example/conf/jboss-web.xml +++ b/java/jca/example/conf/jboss-web.xml @@ -25,6 +25,11 @@ javax.jms.ConnectionFactory java:/QpidJMSXA + + QpidJMS + javax.jms.ConnectionFactory + java:/QpidJMS + QpidTestBean qpid-jcaex/QpidTestBean/local diff --git a/java/jca/example/conf/log4j.properties b/java/jca/example/conf/log4j.properties index f1847f4418..1139ab9e85 100644 --- a/java/jca/example/conf/log4j.properties +++ b/java/jca/example/conf/log4j.properties @@ -1,3 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# log4j.rootLogger=DEBUG, CONSOLE, FILE #Console Appender diff --git a/java/jca/example/conf/qpid-jca-ds.xml b/java/jca/example/conf/qpid-jca-ds.xml index 80fb828b55..ad75876808 100644 --- a/java/jca/example/conf/qpid-jca-ds.xml +++ b/java/jca/example/conf/qpid-jca-ds.xml @@ -27,7 +27,7 @@ jboss.jca:service=RARDeployment,name='@rar.name@' org.apache.qpid.ra.admin.QpidTopic - destinationAddress=@qpid.hello.topic.dest.address@ + DestinationAddress=@qpid.hello.topic.dest.address@ @@ -37,7 +37,7 @@ jboss.jca:service=RARDeployment,name='@rar.name@' org.apache.qpid.ra.admin.QpidTopic - destinationAddress=@qpid.goodbye.topic.dest.address@ + DestinationAddress=@qpid.goodbye.topic.dest.address@ @@ -47,7 +47,7 @@ jboss.jca:service=RARDeployment,name='@rar.name@' org.apache.qpid.ra.admin.QpidTopic - destinationAddress=@qpid.hellogoodbye.topic.dest.address@ + DestinationAddress=@qpid.hellogoodbye.topic.dest.address@ @@ -57,7 +57,7 @@ jboss.jca:service=RARDeployment,name='@rar.name@' org.apache.qpid.ra.admin.QpidQueue - destinationAddress=@qpid.hello.queue.dest.address@ + DestinationAddress=@qpid.hello.queue.dest.address@ @@ -67,27 +67,36 @@ jboss.jca:service=RARDeployment,name='@rar.name@' org.apache.qpid.ra.admin.QpidQueue - destinationAddress=@qpid.goodbye.queue.dest.address@ + DestinationAddress=@qpid.goodbye.queue.dest.address@ - QpidResponderQueue + name="qpid.jca:name=QpidRequestQueue"> + QpidRequestQueue jboss.jca:service=RARDeployment,name='@rar.name@' org.apache.qpid.ra.admin.QpidQueue - destinationAddress=@qpid.responder.queue.dest.address@ + DestinationAddress=@qpid.request.queue.dest.address@ + + QpidResponseQueue + jboss.jca:service=RARDeployment,name='@rar.name@' + org.apache.qpid.ra.admin.QpidQueue + + DestinationAddress=@qpid.response.queue.dest.address@ + + QpidConnectionFactory jboss.jca:service=RARDeployment,name='@rar.name@' javax.jms.ConnectionFactory - connectionURL=@broker.url@ + ConnectionURL=@broker.url@ diff --git a/java/jca/example/conf/qpid-standalone.xml b/java/jca/example/conf/qpid-standalone.xml new file mode 100644 index 0000000000..8d6137aea7 --- /dev/null +++ b/java/jca/example/conf/qpid-standalone.xml @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 + + + h2 + + + + sa + + + sa + + + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + @rar.name@ + + + XATransaction + + + @broker.url@ + + + org.apache.qpid.ra.tm.JBoss7TransactionManagerLocator + + + getTm + + + + + @broker.url@ + + + javax.jms.Queue + + + + + + + @broker.url@ + + + + + @qpid.hello.topic.dest.address@ + + + + + @qpid.goodbye.topic.dest.address@ + + + + + @qpid.goodbye.queue.dest.address@ + + + + + @qpid.hello.queue.dest.address@ + + + + + @qpid.request.queue.dest.address@ + + + + + @qpid.response.queue.dest.address@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + ${jboss.bind.address:127.0.0.1} + + + + Standard-Endpoint-Config + + + + + Recording-Endpoint-Config + + + + + ##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM + + + + RecordingHandler + + + org.jboss.ws.common.invocation.RecordingServerHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jca/example/conf/web.xml b/java/jca/example/conf/web.xml index d87c578606..6e53d7beba 100644 --- a/java/jca/example/conf/web.xml +++ b/java/jca/example/conf/web.xml @@ -29,11 +29,22 @@ 1 + + QpidRequestResponseServlet + QpidRequestResponseServlet + org.apache.qpid.jca.example.web.QpidRequestResponseServlet + 1 + + QpidTestServlet /qpid + + QpidRequestResponseServlet + /qpid-reqresp + diff --git a/java/jca/example/qpid-jca-example-properties.xml b/java/jca/example/qpid-jca-example-properties.xml index eb219a05e1..ab0f6267ba 100644 --- a/java/jca/example/qpid-jca-example-properties.xml +++ b/java/jca/example/qpid-jca-example-properties.xml @@ -45,8 +45,10 @@ value="hello.Queue;{create:always, node:{type:queue, x-declare:{auto-delete:true}}}"/> - + + @@ -58,8 +60,10 @@ value="BURL:direct://amq.direct//hello.Queue?routingkey='hello.Queue'"/> - + + @@ -75,5 +79,6 @@ - + + diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/client/QpidRequestResponseClient.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/client/QpidRequestResponseClient.java index 734df1c0f3..fd5b3efff0 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/client/QpidRequestResponseClient.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/client/QpidRequestResponseClient.java @@ -42,7 +42,7 @@ public class QpidRequestResponseClient implements MessageListener, Runnable private static final Logger _log = LoggerFactory.getLogger(QpidRequestResponseClient.class); private static final String DEFAULT_CF_JNDI = "QpidConnectionFactory"; - private static final String DEFAULT_DESTINATION_JNDI = "QpidResponderQueue"; + private static final String DEFAULT_DESTINATION_JNDI = "QpidRequestQueue"; private static final String DEFAULT_MESSAGE = "Hello, World!"; private static final int DEFAULT_MESSAGE_COUNT = 1; private static final int DEFAULT_THREAD_COUNT = 1; diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeListenerBean.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeListenerBean.java index 9cf220de2a..bdb722a87b 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeListenerBean.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeListenerBean.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), - @ActivationConfigProperty(propertyName = "destination", propertyValue = "@qpid.goodbye.queue.jndi.name@"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "@jndi.prefix@@qpid.goodbye.queue.jndi.name@"), @ActivationConfigProperty(propertyName = "connectionURL", propertyValue = "@broker.url@"), @ActivationConfigProperty(propertyName = "useLocalTx", propertyValue = "false"), @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "10") diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeSubscriberBean.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeSubscriberBean.java index 64e0effb1f..f2e4d6aaa5 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeSubscriberBean.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidGoodByeSubscriberBean.java @@ -34,10 +34,9 @@ import org.slf4j.LoggerFactory; @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "destination", propertyValue = "@qpid.goodbye.topic.jndi.name@"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "@jndi.prefix@@qpid.goodbye.topic.jndi.name@"), @ActivationConfigProperty(propertyName = "connectionURL", propertyValue = "@broker.url@"), @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "NotDurable"), - @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "hello.Topic"), @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "10") }) diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloListenerBean.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloListenerBean.java index 0056e7b0b8..75e0acab79 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloListenerBean.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloListenerBean.java @@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory; @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), - @ActivationConfigProperty(propertyName = "destination", propertyValue = "@qpid.hello.queue.jndi.name@"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "@jndi.prefix@@qpid.hello.queue.jndi.name@"), @ActivationConfigProperty(propertyName = "connectionURL", propertyValue = "@broker.url@"), @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "10") }) @@ -53,7 +53,7 @@ public class QpidHelloListenerBean implements MessageListener @Resource(@jndi.scheme@="@qpid.xacf.jndi.name@") private ConnectionFactory _connectionFactory; - @Resource(@jndi.scheme@="GoodByeQueue") + @Resource(@jndi.scheme@="@qpid.goodbye.queue.jndi.name@") private Destination _queue; @Override diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloSubscriberBean.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloSubscriberBean.java index 560de36e48..882c85fa18 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloSubscriberBean.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidHelloSubscriberBean.java @@ -42,10 +42,9 @@ import org.slf4j.LoggerFactory; @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), - @ActivationConfigProperty(propertyName = "destination", propertyValue = "@qpid.hello.topic.jndi.name@"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "@jndi.prefix@@qpid.hello.topic.jndi.name@"), @ActivationConfigProperty(propertyName = "connectionURL", propertyValue = "@broker.url@"), @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "NotDurable"), - @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "hello.Topic"), @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "10") }) public class QpidHelloSubscriberBean implements MessageListener @@ -55,7 +54,7 @@ public class QpidHelloSubscriberBean implements MessageListener @Resource(@jndi.scheme@="@qpid.xacf.jndi.name@") private ConnectionFactory _connectionFactory; - @Resource(@jndi.scheme@="GoodByeTopic") + @Resource(@jndi.scheme@="@qpid.goodbye.topic.jndi.name@") private Destination _topic; @Override diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidJMSResponderBean.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidJMSResponderBean.java index e7b44e10ca..6e99d4fe7f 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidJMSResponderBean.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidJMSResponderBean.java @@ -27,6 +27,7 @@ import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.jms.Connection; import javax.jms.ConnectionFactory; +import javax.jms.Destination; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.MessageProducer; @@ -40,7 +41,7 @@ import org.slf4j.LoggerFactory; @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), - @ActivationConfigProperty(propertyName = "destination", propertyValue = "@qpid.responder.queue.jndi.name@"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "@jndi.prefix@@qpid.request.queue.jndi.name@"), @ActivationConfigProperty(propertyName = "connectionURL", propertyValue = "@broker.url@"), @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "10") }) @@ -72,10 +73,12 @@ public class QpidJMSResponderBean implements MessageListener temp.append("QpidJMSResponderBean received message with content: [" + content); temp.append("] at " + new Date()); + connection = _connectionFactory.createConnection(); + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + if(message.getJMSReplyTo() != null) { - connection = _connectionFactory.createConnection(); - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _log.info("Sending response via JMSReplyTo"); messageProducer = session.createProducer(message.getJMSReplyTo()); response = session.createTextMessage(); response.setText(temp.toString()); @@ -83,8 +86,10 @@ public class QpidJMSResponderBean implements MessageListener } else { - _log.warn("Response was requested with no JMSReplyToDestination set. Will not respond to message."); + _log.info("JMSReplyTo is null. Will not respond to message."); } + + } } catch(Exception e) diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidTestBean.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidTestBean.java index 014b459699..a5f4770257 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidTestBean.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/ejb/QpidTestBean.java @@ -43,10 +43,10 @@ public class QpidTestBean implements QpidTestRemote, QpidTestLocal @Resource(@jndi.scheme@="@qpid.xacf.jndi.name@") private ConnectionFactory _connectionFactory; - @Resource(@jndi.scheme@="HelloQueue") + @Resource(@jndi.scheme@="@qpid.hello.queue.jndi.name@") private Destination _queue; - @Resource(@jndi.scheme@="HelloTopic") + @Resource(@jndi.scheme@="@qpid.hello.topic.jndi.name@") private Destination _topic; @Override diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidRequestResponseServlet.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidRequestResponseServlet.java new file mode 100644 index 0000000000..d069a0c943 --- /dev/null +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidRequestResponseServlet.java @@ -0,0 +1,283 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.qpid.jca.example.web; +import java.io.IOException; +import java.lang.Thread; + +import javax.annotation.Resource; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.naming.InitialContext; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.transaction.UserTransaction; + +import org.apache.qpid.jca.example.ejb.QpidTest; +import org.apache.qpid.jca.example.ejb.QpidUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("serial") +public class QpidRequestResponseServlet extends HttpServlet +{ + private static final Logger _log = LoggerFactory.getLogger(QpidTestServlet.class); + + private static final String DEFAULT_MESSAGE = "Hello, World!"; + private static final int DEFAULT_COUNT = 1; + private static final boolean DEFAULT_XA = false; + private static final boolean DEFAULT_TX = false; + private static final boolean USE_TMP_QUEUE = false; + + @Resource(@jndi.scheme@="@qpid.xacf.jndi.name@") + private ConnectionFactory _connectionFactory; + + @Resource(@jndi.scheme@="@qpid.request.queue.jndi.name@") + private Destination _queue; + + @Resource(@jndi.scheme@="@qpid.response.queue.jndi.name@") + private Destination _responseQueue; + + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + doPost(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + InitialContext ctx = null; + Connection connection = null; + Session session = null; + MessageProducer messageProducer = null; + UserTransaction ut = null; + boolean useXA = false; + boolean rollback = false; + boolean useTx = false; + MessageConsumer messageConsumer = null; + long startTime = 0; + + try + { + String content = (req.getParameter("message") == null) ? DEFAULT_MESSAGE : req.getParameter("message"); + int count = (req.getParameter("count") == null) ? DEFAULT_COUNT : Integer.valueOf(req.getParameter("count")); + useXA = (req.getParameter("useXA") == null) ? DEFAULT_XA : Boolean.valueOf(req.getParameter("useXA")); + useTx = (req.getParameter("useTx") == null) ? DEFAULT_TX : Boolean.valueOf(req.getParameter("useTx")); + + ctx = new InitialContext(); + + _log.debug("Environment: "); + _log.debug("Message content: " + content); + _log.debug("Message count:" + count); + _log.debug("Using XA: " + useXA); + + resp.getOutputStream().println("Environment: "); + resp.getOutputStream().println("Message content: " + content); + resp.getOutputStream().println("Message count:" + count); + resp.getOutputStream().println("Using XA: " + useXA); + + try + { + + connection = _connectionFactory.createConnection(); + + if(useXA) + { + ut = (UserTransaction)ctx.lookup("java:comp/UserTransaction"); + ut.begin(); + useTx = false; + } + + session = (useXA) ? connection.createSession(false, Session.AUTO_ACKNOWLEDGE) : connection.createSession(useTx, Session.AUTO_ACKNOWLEDGE); + messageProducer = session.createProducer(_queue); + + startTime = System.currentTimeMillis(); + + for(int i = 0; i < count; i++) + { + TextMessage message = session.createTextMessage(content); + message.setJMSReplyTo(_responseQueue); + messageProducer.send(message); + } + + } + catch(Exception e) + { + rollback = true; + + if(useXA && ut != null) + { + try + { + ut.setRollbackOnly(); + } + catch(Exception ex) + { + _log.error(ex.getMessage(), ex); + throw new ServletException(ex.getMessage(), ex); + } + } + } + finally + { + try + { + if(useXA && ut != null) + { + if(rollback) + { + ut.rollback(); + } + else + { + ut.commit(); + } + } + if(useTx && !useXA) + { + if(rollback) + { + session.rollback(); + } + else + { + session.commit(); + } + } + } + catch(Exception e) + { + _log.error(e.getMessage(), e); + throw new ServletException(e.getMessage(), e); + } + + QpidUtil.closeResources(messageProducer, session); + } + + resp.getOutputStream().println("Sent " + count + " messages with content '" + content + "'"); + resp.getOutputStream().flush(); + + int ackMode = Session.AUTO_ACKNOWLEDGE; + rollback = false; + + if(useXA) + { + ut.begin(); + } + + session = (useXA) ? connection.createSession(false, Session.AUTO_ACKNOWLEDGE) : connection.createSession(useTx, Session.AUTO_ACKNOWLEDGE); + messageConsumer = session.createConsumer(_responseQueue); + connection.start(); + + for(int i = 0; i < count; i++) + { + TextMessage message = (TextMessage)messageConsumer.receive(5000); + + if(message != null) + { + message.acknowledge(); + content = message.getText(); + + } + } + + startTime = System.currentTimeMillis() - startTime; + resp.getOutputStream().println("Received " + count + " messages with content '" + content + "'"); + resp.getOutputStream().println("Total process time " + startTime); + } + catch(Exception e) + { + rollback = true; + + if(useXA && ut != null) + { + try + { + ut.setRollbackOnly(); + } + catch(Exception ex) + { + _log.error(ex.getMessage(), ex); + throw new ServletException(ex.getMessage(), ex); + } + } + } + finally + { + if(useXA && ut != null) + { + try + { + if(rollback) + { + ut.rollback(); + } + else + { + ut.commit(); + } + } + catch(Exception e) + { + _log.error(e.getMessage(), e); + throw new ServletException(e.getMessage(), e); + + } + } + + if(useTx && !useXA) + { + try + { + if(rollback) + { + session.rollback(); + } + else + { + session.commit(); + } + } + catch(Exception e) + { + _log.error(e.getMessage(), e); + throw new ServletException(e.getMessage(), e); + } + } + + QpidUtil.closeResources(messageProducer, session); + } + } + +} + + diff --git a/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidTestServlet.java b/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidTestServlet.java index 11a61e762c..7526daa83d 100644 --- a/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidTestServlet.java +++ b/java/jca/example/src/main/java/org/apache/qpid/jca/example/web/QpidTestServlet.java @@ -52,15 +52,16 @@ public class QpidTestServlet extends HttpServlet private static final int DEFAULT_COUNT = 1; private static final boolean DEFAULT_TOPIC = false; private static final boolean DEFAULT_XA = false; + private static final boolean DEFAULT_TX = false; private static final boolean DEFAULT_SAY_GOODBYE = true; @Resource(@jndi.scheme@="@qpid.xacf.jndi.name@") private ConnectionFactory _connectionFactory; - @Resource(@jndi.scheme@="HelloQueue") + @Resource(@jndi.scheme@="@qpid.hello.queue.jndi.name@") private Destination _queue; - @Resource(@jndi.scheme@="HelloTopic") + @Resource(@jndi.scheme@="@qpid.hello.topic.jndi.name@") private Destination _topic; @EJB @@ -82,6 +83,7 @@ public class QpidTestServlet extends HttpServlet UserTransaction ut = null; boolean useXA = false; boolean rollback = false; + boolean useTX = false; try { @@ -90,8 +92,10 @@ public class QpidTestServlet extends HttpServlet int count = (req.getParameter("count") == null) ? DEFAULT_COUNT : Integer.valueOf(req.getParameter("count")); boolean useTopic = (req.getParameter("useTopic") == null) ? DEFAULT_TOPIC : Boolean.valueOf(req.getParameter("useTopic")); useXA = (req.getParameter("useXA") == null) ? DEFAULT_XA : Boolean.valueOf(req.getParameter("useXA")); + useTX = (req.getParameter("useTX") == null) ? DEFAULT_TX : Boolean.valueOf(req.getParameter("useTX")); ctx = new InitialContext(); boolean sayGoodBye = (req.getParameter("sayGoodBye") == null) ? DEFAULT_SAY_GOODBYE : Boolean.valueOf(req.getParameter("sayGoodBye")); + useTX = (req.getParameter("useTX") == null) ? DEFAULT_TOPIC : Boolean.valueOf(req.getParameter("DEFAULT_TX")); _log.debug("Environment: "); _log.debug("Message content: " + content); @@ -122,7 +126,7 @@ public class QpidTestServlet extends HttpServlet } connection = _connectionFactory.createConnection(); - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + session = connection.createSession(useTX, Session.AUTO_ACKNOWLEDGE); messageProducer = (useTopic) ? session.createProducer(_topic) : session.createProducer(_queue); for(int i = 0; i < count; i++) @@ -155,6 +159,19 @@ public class QpidTestServlet extends HttpServlet } } + if(useTX) + { + try + { + session.rollback(); + } + catch(Exception ex) + { + _log.error(ex.getMessage(), ex); + throw new ServletException(ex.getMessage(), ex); + } + } + _log.error(e.getMessage(), e); throw new ServletException(e.getMessage(), e); } @@ -181,12 +198,32 @@ public class QpidTestServlet extends HttpServlet } } + if(useTX && !useXA) + { + try + { + + if(rollback) + { + session.rollback(); + } + else + { + session.commit(); + } + } + catch(Exception e) + { + + _log.error(e.getMessage(), e); + throw new ServletException(e.getMessage(), e); + } + } + QpidUtil.closeResources(session, connection, ctx); } } - - } -- cgit v1.2.1