Tuesday, August 22, 2017

How to Provision an Oracle Java Cloud Service Instance

Oracle Cloud helps to rapidly develop and deploy scalable enterprises, reduce cost of ownership and take advantage of the best that oracle public cloud has to offer.

Java Cloud Service is a component of Oracle's SaaS offering which allows to bring data center directly to cloud. It is a one stop shop for all Java Enterprise Edition needs.

In this blog, we will see the step by step process to create an Oracle Java Cloud Service Instance.

Following are major steps involved -

1) Creation of Trial account - For this blog, we will go with a trial account
2) Generate SSH keys
3) Create an Oracle Database Cloud instance
4) Create an Oracle Java Cloud Service instance

Creation of Trial Account:


1) Open https://cloud.oracle.com page. Click on the Free Trial button at the top right of the screen as shown in the below screen shot.


2) Following screen would be shown with the steps to create Oracle cloud account. Click on View Details & Sign Up.


3) On the following screen, click on Get started for free button.


4) Fill up the details on the next few screens and submit. A trial account would be created.


5) You would receive a mail with Oracle cloud access details. Please note the username and password in the mail. Using this username and password, Sign in to https://cloud.oracle.com

Once you click on SignIn, you would see the following screen. Choose the data center and click on My Services to login. You can find the details of your data center in the access mail you received.


6) In the next screen, enter the identity domain, user name and password. If you are logging in for the first time, you would be prompted to change the password and update some security questions.

7)  Once you have successfully logged in, you would see the Dashboard screen.

This way you can successfully create a Trial account.

Generate SSH Keys:


There are many ways to generate SSH keys. In this blog, we will create them through PuttyGen. 

1) Install PuttyGen into your system. Click on PuttyGen. Following browser would appear.

Before generating the key, choose the parameters as follows.

  • Type of Key - SSH-2 RSA
  • Number of bits should be 2048
Now click on Generate button.


2) Once you click on Generate, following screen would appear. In the blank space above Actions, keep moving your cursor to create some randomness until the key is generated.


3) Once the key is generated, screen looks as follows.


4)  Enter the passphrase for the key.


5) Key Generator generates two keys - public key and private key.

In order to export private key, click on Conversions -> Export OpenSSH key.


Save the private key in a location with .prv extension.


6) You can find the public key in the "Public key for pasting into OpenSSH authorized_keys file" section. To export the public key, manually copy the key from this section and save it in the same location as private key with .pub extension.




In this way, we have both public and private key pair generated.

Create an Oracle Database Cloud Instance:


1) Login to https://cloud.oracle.com as mentioned in Creation of Trial Account section.

Once done, you would see a dashboard screen. You should be able to see sections like Java, Database below the Cloud Services section. If you cannot find these sections, click on Customize Dashboard on the top right.


2) Following screen would appear where you can choose which section to appear and which to be hidden in the dashboard. Click on Show icon next to Database and Java, so that these two can be seen on dashboard.


3) The dashboard gets updated with Java and Database sections.


4) Now click on Database -> View details. It will open an overview screen which will show details about the plan or service details for your account. Click on Open Service Console button at the top right.

5) Click Go to Console.


6) Database Cloud Instance console contains multiple tabs like Services, Activity, SSH Access etc. As you have not created any service yet, the screen will show a message that you do not have any services.

To start provisioning a Database Cloud Service, click on Create Service button in the console.


10) Screen will navigate to Basic Service information section. Enter the below details.
  • Service Name - Name as per your choice. PGJCSDB in my case.
  • Description - Optional description about the instance to be created. Can be anything.
  • Notification Email - Will be defaulted by your email address associated with the account.
  • Service Level - You do not need a Virtual Image. Hence, choose Oracle Database Cloud Instance
  • Metering Frequency - Can be Hourly or Monthly. Choose Monthly
  • Software Release - Cloud instance can be created on both 11g and 12c versions. Here we use Oracle Database 12c Release 1
  • Software Edition - Enterprise Edition would suffice
  • Database Type - Single Instance

Once the above details are filled out, click on Next button.


11) Service Details page will open. In this page, we will enter all the configuration details required to setup an Oracle Database instance.

  • DB Name - Defaulted to ORCL. 
  • PDB Name - Defaulted to PDB1.
  • Administrative Password and Confirm Password - Enter the password that you would want to use to connect to this cloud DB.
  • Usable Data Storage - Change to 15
  • Total Data File Storage - Once Usable Data Storage is modified, this field gets updated accordingly
  • Compute Shape - Through this field, you can choose the CPU and Memory required for the DB. In this case, OC3 - 1.0 OCPU, 7.5 GB RAM
  • SSH Public Key - Here we would use the public key generated through PuttyGen in the initial steps.


Click on Edit adjacent to SSH Public Key field, choose the .pub key from the location where we initially saved.



  • Backup Destination - Both Cloud Storage and Local Storage
  • Cloud Storage Container - This is the location where the backup files would be stored. As the storage container does not exist, we would need to create it as part of this step. Format of storage container - Storage-<IdentityDomain>/storagename. In my case, Storage-pgcloud/dbcsbackup
  • Username and Password - Credentials of the cloud account
  • Create Cloud Storage Container - Check the field as a new storage container needs to be created.
Leave the rest of the fields as-is and click next.


Sometimes you would encounter the following error when you click on next in the above screen.

"Error: Creation of cloud storage container, Storage-XXX/XXXX", failed: Unexpected error occured".

This error is specific to creation of storage container. In order to avoid this error, you can create the storage container separately and associate it here. When the storage container is already existing, you will have to uncheck the "Create Cloud Storage Container" check box.

How to create Storage Container:

Go to home page -> Dashboard, Click on Storage. If you do not find Storage, use the Customize Dashboard to show the Storage section.



Enter the Storage container name. Select Storage Class as Standard. Now click Create.


Once the Storage Container is created, you can see them in the Container list. The path for the container would be as follows - <StorageName>/<ContainerName>

Storage name - The name as shown on the top left. Here - Storage-pgcloud
Container name - Here - dbcsbackup


If you do not encounter the storage container issue, proceed to the next step, which will show the Confirmation page of DB Cloud instance.

If all the information is correct, click on Create. Oracle Database Cloud Instance creation process would start now. You would see the following screen. Typically, creation of this instance would take 10-20 minutes or even more. Mine took around 2 hours.


Once the DB cloud instance is created, you can find the details in console as follows. 


Create an Oracle Java Cloud Service Instance:


1) Similar to the first point of Create Oracle Database Cloud instance, go to the cloud dashboard.

2) Click Java -> Open Service Console.



3) Click on Go to Console.



4) In the Java Cloud Service console, click on Create Service -> Java Cloud Service.



5) Enter the basic service information in the following screen.

  • Service Name - As per your choice. In my case, PGJCS
  • Service Description - Meaningful description for the service instance.
  • Notification Email - Default mail address associated to your account
  • Service Level - For this blog, we will go with Oracle Java Cloud Service
  • Software Release - Oracle Weblogic Service 12c, 12.2.1.2
  • Metering Frequency - Monthly

Click next.


6) Enter the detailed Service information in the next screen.

Weblogic Configuration:
  • Compute Shape - Choose the CPU, Memory to be allocated to the VM through this field. I chose OC3 - 1.0 OCPU, 7.5 GB RAM
  • SSH Public Key - Click on edit button, navigate to the location of ssh key and choose the .pub file created in Generate SSH Keys section.
  • Cluster Size - Defines the number of managed servers in weblogic cluster. Set it to 2. 

Weblogic Access:
  • Local Administrative Username, Password - create a username and password for admin access.

Database Configuration:
  • Name - In the dropdown, you would find the option of the DB instance you created in the previous section. Choose that.
  • PDB Name - Gets defaulted based on the DB instance selected.
  • Administrator Username and Password - These would be the credentials that you gave while creating Database Cloud instance.



Load Balancer:
  • Load Balancer - If cluster size is one, this field will be defaulted to No. If the cluster size is more than one, this field will be defaulted to Yes. As we need load balancing, we will leave it to Yes.
  • Compute Size - Choose the Oracle Compute Units and Memory. In this case, OC3 - 1.0 OCPU, 7.5GB RAM.
  • Add Another Active OTD Node - No. We need only one instance of load balancing. Hence, we do not need to add Oracle Traffic Director.
  • Load Balancer Policy - Least Connection Count.

Backup and Recovery Configuration:
  • Backup Destination: Both Cloud Storage and Local Storage
  • Cloud Storage Container - Follow the same convention as mentioned in DB Cloud instance section.
  • Storage-<IdentityDomain>/<ContainerName> Eg:Storage-pgcloud/jcsbackup
  • Username and Password - Credentials of the cloud account
  • Create Cloud Storage Container - Check

Click Next.


7) If the storage container gets created successfully, you will get a success message and a confirmation screen will all the entered details. If all the details are correct, click on Create.


8) Java Cloud Service creation is in process now. 



9) Once the JCS instance is created, you can view the details as follows.

Java Cloud Service Instance Console

In this way, an Oracle Java Cloud Service instance is created.

Once the DB Cloud Instance and JCS Instances are created, dashboard looks as follows. You can see that the instances count are one for both of them.


Let's quickly explore the different consoles of JCS.

Explore Java Cloud Service Instance:

In the above mentioned section, click on the name of the newly created JCS instance (In my case PGJCS).

You can find the complete service instance details here.

Overview: This section on the left shows the number of the nodes in the instance.

Administration: You can find the details about any applicable or applied patches.

Service Overview: In this section, you can find the summary of Java Cloud Service instance element details like the number of Compute units, Memory allocated, Storage and the number of Public IPs.

Weblogic Resources: This section in the center shows the details of Admin server domain, which includes Admin and Managed server information, and the coherence layer.

Load Balancer Resources: As the weblogic cluster is 2, load balancer instance has been created. You can find the details in this section.

Associations: This section shows the associated instances. In this case, DB cloud instance is the associated one and hence you can see it here.

Through this screen, many operations can be performed on Java Virtual Machines(JVMs) like starting, stopping JVMs, scaling, backups, patching, etc.



Go back to the Java Cloud Service Instance Console. Click on the properties icon on the right of the newly created JCS instance. You can find the links to several consoles here.

Weblogic Service Console - This console provides the means to perform management operations on weblogic servers like start, stop, restart, deployment of java services, etc.

Fusion Middleware Control Console - This console is specifically for Fusion Middleware components like SOA, BPEL, etc

Load Balancer Console - Oracle Traffic Director console to perform operations on load balancer instance.






Referred links: http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/javaservice/JCS/Get_Started_with_JCS/Get_Started_with_JCS_OPCM.html




Thursday, August 3, 2017

Working with Human Workflow in SOA 12c

Human workflow in SOA allows a manual action to be performed on a pending or running business process before it can proceed further. This workflow is mainly used to aid the functionality of taking business decisions at run time.

In this blog, we would see an example of how to work with human workflow/tasks in SOA 12c.

Our use case is a simple leave approval process, where the leave requests are submitted to manager for approval. The manager can then manually approve/reject/defer the request.

How to create the project:


1. Create an empty SOA composite project. I have named mine as PGHumanWorkflowProject.

2. I have created a simple LeaveApplication.xsd for the project. It goes something like this. The request element - LeaveRequest has 3 fields to convey the details of the leave. The response element LeaveResponse has only one field RequestStatus which provides the status of the leave request once an action has been performed on it.


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="www.pgservices.com/leaveapplication"
            targetNamespace="www.pgservices.com/leaveapplication" elementFormDefault="qualified">
  <xsd:element name="LeaveRequest">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="NoOfDays"/>
        <xsd:element name="Reason"/>
        <xsd:element name="TypeOfLeave">
          <xsd:simpleType>
            <xsd:restriction base="xsd:string">
              <xsd:enumeration value="Earned Leave"/>
              <xsd:enumeration value="Sick Leave"/>
              <xsd:enumeration value="Loss of Pay"/>
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="LeaveResponse">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="RequestStatus">
         <xsd:simpleType>
            <xsd:restriction base="xsd:string">
              <xsd:enumeration value="APPROVED"/>
              <xsd:enumeration value="REJECTED"/>
              <xsd:enumeration value="PENDING"/>
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>


3. Now create an Asynchronous BPEL process in the empty composite and give a name. PGHumanWFProject in my case. As this process does not receive a response until a human action is taken, an asynchronous process needs to be created.

4. Update the default input and output variables to the LeaveRequest and LeaveResponse elements from the above created schema and complete BPEL creation.

5. The auto generated wsdl looks as follows with two port types - One for invocation and other for callback.


6. Next step is to start with the Human workflow. Insert a Human Task activity in the composite.


7. In the Create Human Task wizard, provide a name and click ok.


8. Double click on the Human Task. Following screen will appear.


9. Click on the right most icon in the Task Title row. An Expression Builder window will open. Enter the title you would want for the Human task. Add a meaningful description in the task window.


10. Next click on the outcome field. A dialog appears with all the options to choose. APPROVE, REJECT and DEFER are my possible outcomes. Click OK.


11. Now click the next tab in the left section which is the Data tab. Through this screen, you can map the input that needs to be passed to this Human task activity. We need to pass the Leave Request as xml to human task.

       a. Hence, click on the + icon to the right of data and choose "Add other parameter". In the Add Task Parameter, select Element button and the click on the torch next to it.
       b. Select LeaveRequest in the Type Chooser window and click ok for the two screens.


12. Click on the Assignment tab in the left section. This screen allows you to add the user who can access the leave task request. Say for example, there is a user/login named - testuser defined in administration console. You can add this user as a participant here, so that only testuser can access this request and perform any action upon it.


13. Select "Single Participant" icon from the components and drop into the drop participant section in Assignment tab as follows.


14. Click on Edit Participant for the following window to open. Under Participant Names, click on +. Select Identification Type as User, Data Type as By Name and Value as the userId whom you would want to give the access. In my case, I would want weblogic user to take action on the task created through this process.
Click on OK.


15. Now you are back to the task screen. The task has been created successfully. In the left top, you would see a button called Form. Click the Auto-Generate Task Form under Form dropdown. This will create a UI application for the form.


16. A popup would come up where you can enter the name of the UI project and then click OK.


17. An ADF webproject is created with the details you provide. Once, all the files are generated as part of the ADF project. Save and close all.

18. Back in the composite page, connect the BPEL composite to the Human Task component. Composite.xml looks as follows.


19. Open the BPEL process. Drag a Human Task SOA component and drop it below Receive activity.


20. Choose the Task Definition as the one that we created in the earlier steps and click on Ok.


21. Once, you choose Task Definition, the task screen gets loaded with the additional details. Under Task Parameters section, you would already see the Parameter as LeaveRequest. Click on the button under BPEL variable. Choose LeaveRequest element under inputVariable. This will ensure that the inputVariable element is mapped directly to the human task input.


22. Once you click OK, you will see that the BPEL has Human task component as well as Switch activities created for each of the possible outcomes chosen earlier.

As I chose, APPROVE, REJECT and DEFER as outcomes, you would see three switch branches in addition to the default branch.


23. Expand the LeaveApplnHumanTaskDefinition2 activity. You would see an invoke activity which calls the human task and receive activity which waits for the callback response once an action is taken on the request.


24. The conditions in the switch activity are already populated with appropriate conditions as follows.


25. You can also see that each sequence in the switch already has Assign activities. By default, the payload of the task response is mapped to input variable of the BPEL. You can delete that mapping.

Instead map as follows - 
The task response variable -> systemAttributes -> outcome field maps to outputVariable -> LeaveResponse -> RequestStatus.


26. Update the mappings similarly in all the sequences. In the default sequence, instead of mapping the outcome, you can just hard the RequestStatus to INVALID RESPONSE.


27. Now we are done with the BPEL project with Human task. Deploy it to the SOA server. While deployment, you would see a task flow deployment page, where you would have to select the UI project that got generated when the Human task was created. This makes sure that the SOA project is deployed along with the UI project.


Test the project:


1. Go to em console and click on the test button of this project.
2. Enter the input arguments as follows and click on Test webservice.


3. In the flow trace of the tested instance, you would see that the LeaveApplnHumanTaskDefinition is in Running state. This means that the task has been submitted and someone should act upon the request.


4. In order to perform an action on the task, login to the worklist app using the following URL. Login with the user that you added in the Add Participant tab. In my case, I added as weblogic user.

http://<serverhostname:portnumber>/integration/worklistapp

5. In the worklist app, you can see the Leave Application task as follows. Select the task and from the Actions dropdown and choose appropriate action. I choose Approve. You would see that the task vanishes from the tasks screen.


6. Now go back to the em console and open the instance that was running earlier. You would see the status of the human task as completed now


7. Click on the Task definition, you can find the Outcome as APPROVE.


 8. The BPEL response variable is also populated with the outcome as per the mapping as follows.