Cloud: Java Cloud Service SDK

#

## Sample Introduction

This sample is a Maven project that allows you to deploy message-driven beans (MDBs). The deployed MDBs will listen on local destinations (queue and topic) that are automatically created as part of the local JMS configuration. The connection factory is registered in JNDI as `local-connection-factory` while the queue and topic are registered as `local-queue` and `local-topic`, respectively.

For details about the sample code, see the files that are listed in the following table.

## Main Files Used in the Sample

Directory Location:

SDK_HOME/samples/maven/messagedrivenbean

(where SDK_HOME is the directory containing your Java Cloud Service installation)

File Click source files to view code. | Description
--- | ---
pom.xml | Project Object Model file that contains information about the project and configuration details used by Maven to build the project.
messagedrivenbean-ear | Maven project module for EAR file packaging.
messagedrivenbean-module | Maven project module for MDB code and configuration.
QueueMessageBean.java | MDB class that listens on the local queue.
TopicMessageBean.java | MDB class that listens on the local topic.
weblogic-ejb-jar.xml | Oracle WebLogic Server-specific EJB deployment descriptor.

## Prepare the Sample

### Prerequisites for Installing the Maven Plug-in

Each Maven goal supports all of its corresponding CLI command arguments as properties. To install the Maven plug-in (maven-javacloud.jar), follow these steps:

1. Unzip the SDK and set an environment variable `SDK_HOME` that points to the unzipped directory.
   For example: `export SDK_HOME=/home/user/oracle-javacloud-sdk`
2. `mvn install:install-file -Dfile=$SDK_HOME/lib/maven-javacloud.jar -DpomFile=$SDK_HOME/doc/resources/javacloud.pom`

You can also refer to the Java Cloud Service SDK Tools Documentation: Maven Plugin for more details.

## Build and Install the Sample from the SDK

To build and install the sample, follow these steps:

1. Change to the `SDK_HOME/samples/maven/messagedrivenbean` directory,
   where SDK_HOME refers to the main Oracle Java Cloud Service SDK installation directory, such as `/home/user/oracle-javacloud-sdk`
2. Update the following `pom.xml` properties with the correct values. You can also pass these properties on the command line. For example: `-Duser=myusername`
   - `<local>false</local>` Set local to true is you want to install the sample in local environment
   - `<adminurl>adminurl</adminurl>` Note: adminurl must be specified when `local=true`. When `local=false`, either datacenter(default value is us1) or adminurl has to be specified.
   - `<user>user</user>`
   - `<identitydomain>id</identitydomain>`
   - `<serviceinstance>si</serviceinstance>`
3. `mvn install -DSDK_HOME=$SDK_HOME -Dpassword=pwd`

Use `-Dlocal=true` and `-Dclasspath=<path to weblogic.jar>` when you are deploying to a local Weblogic domain.

You can also refer to Java Cloud Service SDK Tools Documentation: Maven Plugin for more details.

## Run the Sample

1. Complete the steps in the "Prepare the Sample" section and "Build and Install the Sample from the SDK" section.
2. Once deployed, the MDBs will listen on the local queue and topic. Any messages sent to these destinations will be consumed by this sample application.