Skip to content

Commit 90f4b5a

Browse files
committed
Merge pull request wildfly#11 from jmesnil/helloworld-mdb-openshift
Add OpenShift deployment instructions
2 parents 7dd0512 + 89a7f02 commit 90f4b5a

File tree

1 file changed

+220
-1
lines changed

1 file changed

+220
-1
lines changed

helloworld-mdb/README.md

Lines changed: 220 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This project creates two JMS resources:
2020
* A queue named `HELLOWORLDMDBQueue` bound in JNDI as `java:/queue/HELLOWORLDMDBQueue`
2121
* A topic named `HELLOWORLDMDBTopic` bound in JNDI as `java:/topic/HELLOWORLDMDBTopic`
2222

23+
These destinations are automatically created when the project is deployed on WildFly thanks to the [src/main/webapp/WEB-INF/hornetq-jms.xml](hornetq-jms.xml file).
2324

2425
System requirements
2526
-------------------
@@ -48,7 +49,7 @@ Start WildFly 8 with the Full Profile
4849
Build and Deploy the Quickstart
4950
-------------------------
5051

51-
_NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See [Build and Deploy the Quickstarts](../README.md#buildanddeploy) for complete instructions and additional options._
52+
_NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See [Build and Deploy the Quickstarts](../README.md#build-and-deploy-the-quickstarts) for complete instructions and additional options._
5253

5354
1. Make sure you have started the JBoss Server as described above.
5455
2. Open a command line and navigate to the root directory of this quickstart.
@@ -101,3 +102,221 @@ If you want to debug the source code or look at the Javadocs of any library in t
101102

102103
mvn dependency:sources
103104
mvn dependency:resolve -Dclassifier=javadoc
105+
106+
107+
Build and Deploy the Quickstart - to OpenShift
108+
-------------------------
109+
110+
### Create an OpenShift Account and Domain
111+
112+
If you do not yet have an OpenShift account and domain, [Sign in to OpenShift](https://openshift.redhat.com/app/login) to create the account and domain. [Get Started with OpenShift](https://openshift.redhat.com/app/getting_started) will show you how to install the OpenShift Express command line interface.
113+
114+
### Create the OpenShift Application
115+
116+
Open a shell command prompt and change to a directory of your choice. Enter the following command for quickstarts running on WildFly 8:
117+
118+
rhc app create helloworldmdb https://cartreflect-claytondev.rhcloud.com/reflect?github=openshift-cartridges/openshift-wildfly-cartridge
119+
120+
The domain name for this application will be `helloworldmdb-<YOUR_DOMAIN_NAME>.rhcloud.com`. Here we use the _quickstart_ domain. You will need to replace it with your own OpenShift domain name.
121+
122+
This command creates an OpenShift application called `helloworldmdb` and will run the application inside the `wildfly-8` container. You should see some output similar to the following:
123+
124+
The cartridge 'https://cartreflect-claytondev.rhcloud.com/reflect?github=openshift-cartridges/openshift-wildfly-cartridge' will
125+
be downloaded and installed
126+
127+
Application Options
128+
-------------------
129+
Domain: quickstart
130+
Cartridges: https://cartreflect-claytondev.rhcloud.com/reflect?github=openshift-cartridges/openshift-wildfly-cartridge
131+
Gear Size: default
132+
Scaling: no
133+
134+
Creating application 'helloworldmdb' ...
135+
136+
...
137+
138+
Your application 'helloworldmdb' is now available.
139+
140+
Run 'rhc show-app helloworldmdb' for more details about your app.
141+
142+
The create command creates a git repository in the current directory with the same name as the application. Notice that the output also reports the URL at which the application can be accessed. Make sure it is available by typing the published url <http://helloworldmdb-quickstart.rhcloud.com/> into a browser or use command line tools such as curl or wget. Be sure to replace the `quickstart` in the URL with your domain name.
143+
144+
### Configure the OpenShift Server
145+
146+
The messaging subsystem is not enabled by default in the `.openshift/config/standalone.xml`.
147+
148+
We must add this messaging subsystem to be able to use JMS from OpenShift.
149+
150+
Edit `.openshift/config/standalone.xml` and add the `org.jboss.as.messaging` to the extension list:
151+
152+
<extension module="org.jboss.as.messaging"/>
153+
154+
In the `ejb3` subsystem configuration, you also need to add configuration for the Message-Driven Beans in the `<mdb>` element:
155+
156+
<subsystem xmlns="urn:jboss:domain:ejb3:2.0">
157+
<session-bean>
158+
...
159+
</session-bean>
160+
<mdb>
161+
<resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:hornetq-ra.rar}"/>
162+
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
163+
</mdb>
164+
...
165+
</subsystem>
166+
167+
Finally we will configure the messaging subsystem by copying its configuration from WildFly 8.0.0.Final Full configuration profile:
168+
169+
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
170+
<hornetq-server>
171+
<persistence-enabled>true</persistence-enabled>
172+
<journal-file-size>102400</journal-file-size>
173+
<journal-min-files>2</journal-min-files>
174+
<connectors>
175+
<http-connector name="http-connector" socket-binding="http">
176+
<param key="http-upgrade-endpoint" value="http-acceptor"/>
177+
</http-connector>
178+
<http-connector name="http-connector-throughput" socket-binding="http">
179+
<param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
180+
<param key="batch-delay" value="50"/>
181+
</http-connector>
182+
<in-vm-connector name="in-vm" server-id="0"/>
183+
</connectors>
184+
<acceptors>
185+
<http-acceptor name="http-acceptor" http-listener="default"/>
186+
<http-acceptor name="http-acceptor-throughput" http-listener="default">
187+
<param key="batch-delay" value="50"/>
188+
<param key="direct-deliver" value="false"/>
189+
</http-acceptor>
190+
<in-vm-acceptor name="in-vm" server-id="0"/>
191+
</acceptors>
192+
<security-settings>
193+
<security-setting match="#">
194+
<permission type="send" roles="guest"/>
195+
<permission type="consume" roles="guest"/>
196+
<permission type="createNonDurableQueue" roles="guest"/>
197+
<permission type="deleteNonDurableQueue" roles="guest"/>
198+
</security-setting>
199+
</security-settings>
200+
<address-settings>
201+
<!--default for catch all-->
202+
<address-setting match="#">
203+
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
204+
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
205+
<redelivery-delay>0</redelivery-delay>
206+
<max-size-bytes>10485760</max-size-bytes>
207+
<address-full-policy>PAGE</address-full-policy>
208+
<page-size-bytes>2097152</page-size-bytes>
209+
<message-counter-history-day-limit>10</message-counter-history-day-limit>
210+
</address-setting>
211+
</address-settings>
212+
<jms-connection-factories>
213+
<connection-factory name="InVmConnectionFactory">
214+
<connectors>
215+
<connector-ref connector-name="in-vm"/>
216+
</connectors>
217+
<entries>
218+
<entry name="java:/ConnectionFactory"/>
219+
</entries>
220+
</connection-factory>
221+
<connection-factory name="RemoteConnectionFactory">
222+
<connectors>
223+
<connector-ref connector-name="http-connector"/>
224+
</connectors>
225+
<entries>
226+
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
227+
</entries>
228+
</connection-factory>
229+
<pooled-connection-factory name="hornetq-ra">
230+
<transaction mode="xa"/>
231+
<connectors>
232+
<connector-ref connector-name="in-vm"/>
233+
</connectors>
234+
<entries>
235+
<entry name="java:/JmsXA"/>
236+
<!-- Global JNDI entry used to provide a default JMS Connection factory to EE application -->
237+
<entry name="java:jboss/DefaultJMSConnectionFactory"/>
238+
</entries>
239+
</pooled-connection-factory>
240+
</jms-connection-factories>
241+
</hornetq-server>
242+
</subsystem>
243+
244+
Once the `standalone.xml` is edited, we can commit the file to Git and push to OpenShift to restart WildFly 8 with this configuration:
245+
246+
git add .openshift/config/standalone.xml
247+
git ci -m "add messaging subsystem to WildFly standalone configuration"
248+
git push
249+
250+
Once the push command returns, WildFly 8 has been restarted with the messaging configuration.
251+
252+
### Migrate the Quickstart Source
253+
254+
Now that you have confirmed it is working you can migrate the quickstart source. You do not need the generated default application, so navigate to the new git repository directory and tell git to remove the source and pom files:
255+
256+
git rm -r src pom.xml
257+
258+
Copy the source for the `helloworld-mdb` quickstart into this new git repository:
259+
260+
cp -r QUICKSTART_HOME/helloworld-mdb/src .
261+
cp QUICKSTART_HOME/helloworld-mdb/pom.xml .
262+
263+
The `helloworld-mdb` POM file needs to be changed slightly to be able to build and deploy the project from this new location.
264+
265+
Edit the copied `pom.xml`, remove the `<parent>` element and add `<groupId>` and `<version>` elements:
266+
267+
<groupId>org.wildfly.quickstarts</groupId>
268+
<artifactId>wildfly-helloworld-mdb</artifactId>
269+
<packaging>war</packaging>
270+
<version>8.0.0-SNAPSHOT</version>
271+
<name>WildFly Quickstarts: Helloworld Message-Driven Bean with Servlet 3.0 as client</name>
272+
273+
You also need to add the following properties:
274+
275+
<properties>
276+
<version.jboss.spec.javaee7>1.0.0.Final</version.jboss.spec.javaee7>
277+
<version.war.plugin>2.3</version.war.plugin>
278+
</properties>
279+
280+
### Deploy the OpenShift Application
281+
282+
You can now deploy the changes to your OpenShift application using git as follows:
283+
284+
git add src pom.xml .openshift
285+
git commit -m "helloworld-mdb quickstart on OpenShift"
286+
git push
287+
288+
The final push command triggers the OpenShift infrastructure to build and deploy the changes.
289+
290+
Note that the `openshift` profile in the `pom.xml` file is activated by OpenShift. This causes the WAR built by OpenShift to be copied to the `deployments` directory and deployed without a context path.
291+
292+
### Test the OpenShift Application
293+
294+
When the push command returns you can test the application by getting the following URL either via a browser or using tools such as curl or wget. Be sure to replace the `quickstart` in the URL with your domain name.
295+
296+
* <http://helloworldmdb-quickstart.rhcloud.com/> to send messages to the queue
297+
* <http://helloworldmdb-quickstart.rhcloud.com/HelloWorldMDBServletClient?topic> to send messages to the topic
298+
299+
If the application has run succesfully you should see some output in the browser.
300+
301+
Now you can look at the output of the server by running the following command:
302+
303+
rhc tail -a helloworldmdb
304+
305+
This will show the tail of the servers log which should show something like the following.
306+
307+
2012/03/02 05:52:33,065 INFO [class org.jboss.as.quickstarts.mdb.HelloWorldMDB] (Thread-0 (HornetQ-client-global-threads-1772719)) Received Message from queue: This is message 4
308+
2012/03/02 05:52:33,065 INFO [class org.jboss.as.quickstarts.mdb.HelloWorldMDB] (Thread-1 (HornetQ-client-global-threads-1772719)) Received Message from queue: This is message 1
309+
2012/03/02 05:52:33,067 INFO [class org.jboss.as.quickstarts.mdb.HelloWorldMDB] (Thread-6 (HornetQ-client-global-threads-1772719)) Received Message from queue: This is message 5
310+
2012/03/02 05:52:33,065 INFO [class org.jboss.as.quickstarts.mdb.HelloWorldMDB] (Thread-3 (HornetQ-client-global-threads-1772719)) Received Message from queue: This is message 3
311+
2012/03/02 05:52:33,065 INFO [class org.jboss.as.quickstarts.mdb.HelloWorldMDB] (Thread-2 (HornetQ-client-global-threads-1772719)) Received Message from queue: This is message 2
312+
313+
314+
You can use the OpenShift command line tools or the OpenShift web console to discover and control the application.
315+
316+
### Delete the OpenShift Application
317+
318+
When you are finished with the application you can delete it as follows:
319+
320+
rhc app-delete -a helloworldmdb
321+
322+
_Note_: There is a limit to the number of applications you can deploy concurrently to OpenShift. If the `rhc app create` command returns an error indicating you have reached that limit, you must delete an existing application before you continue.

0 commit comments

Comments
 (0)