SlideShare a Scribd company logo
An Oracle Technical Article
July 11




ORACLE SERVICE BUS AND ORACLE
COHERENCE: AN IN-PROCESS AND OUT-
OF-PROCESS CACHE EXAMPLE

                              by William Markito Oliveira
                                       Senior Technologist
                              Platform Technology Services
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example


                                               TABLE OF CONTENTS
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example ................................. 1
   Introduction ......................................................................................................................................................................... 3
      Requirements................................................................................................................................................................... 3
   Our Problematic Web Service ........................................................................................................................................... 3
      Web Service Project ........................................................................................................................................................ 3
   Oracle Service Bus Project.................................................................................................................................................. 7
      Import Web Service Resources ..................................................................................................................................... 7
      Create Proxy and Business Services ............................................................................................................................. 8
      Activate and Test ............................................................................................................................................................ 9
   Oracle Coherence Integration ......................................................................................................................................... 11
      Activating Cache for Business Service ....................................................................................................................... 11
      Coherence console integration with Oracle Service Bus Cache.............................................................................. 13
      Creating a new external coherence server from Weblogic console........................................................................ 15
      Out-of-process caching with external Coherence server ......................................................................................... 19
      Set internal Coherence server Storage to False ......................................................................................................... 20
   Conclusion ......................................................................................................................................................................... 22
   References .......................................................................................................................................................................... 22
   About the Author .............................................................................................................................................................. 22




TABLE OF FIGURES
Figure 1 - New Web Service Project ..................................................................................................................................... 4
Figure 2 - New XML Schema ................................................................................................................................................ 4
Figure 3 - Generate Java Classes from XML Schema using JAXB .................................................................................... 5
Figure 4 - Problematic Web Service Response .................................................................................................................... 7
Figure 5 - Import WSDL Resource into Oracle Service BUS ............................................................................................. 8
Figure 6 - Business Service Creation .................................................................................................................................... 9
Figure 7 - Request With Performance Problems............................................................................................................... 10
Figure 8 - Web Service RESPONSE After 9 seconds ........................................................................................................ 10
Figure 9 - How Result Caching Works .............................................................................................................................. 11
Figure 10 - Enable Business Service Result Cache ............................................................................................................ 12
Figure 11 - Business Service Caching Settings .................................................................................................................. 12
Figure 12 - Adding a New machine ................................................................................................................................... 16
Figure 13 - Node Manager Properties ................................................................................................................................ 16
Figure 14 – Creating a New Coherence Server ................................................................................................................. 17
Figure 15 - Coherence Server Settings................................................................................................................................ 18


An Oracle Technical Article                                                                                                                                                     Page 2
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example




INTRODUCTION
        Since version 11g Oracle Service Bus provides a built-in cache functionality that features Oracle
Coherence offering a first class support for many caching strategies. This article describes how to use these
functionalities and explore a fail-over scenario with an example of how caching strategies can speed up your
Web Services and even prevent production outages.

REQUIREMENTS


                   Software                                 Version                          Description
Oracle Service Bus                                          11.1.1.4                    Enterprise Service Bus-
Oracle Coherence                                              3.6                       Data Grid Cache Server
Weblogic Server                                              10.3.4                      Application Server
Linux or Windows                                             N/A                          Operating System
Oracle Enterprise Pack for Eclipse (OEPE)                     3.6                                IDE


This article is written considering the reader already has knowledge in the following areas:

    •   Java and Web Services
    •   Basic Oracle Service Bus Knowledge
    •   Basic Weblogic Server Administration
    •   Has one Oracle Service Bus domain up and running.


OUR PROBLEMATIC WEB SERVICE
        In our case study, we have a simple Web Service called CustomerService that is currently with some
performance problems and for every request, it is spending 9 seconds to respond. In the section below there are
the steps to create and simulate this “problematic” web service.

WEB S ERVICE PROJECT

            1.   Start Oracle Enteprise Pack Eclipse
            2.   In the New Project window, select Web Service Project and click Next




An Oracle Technical Article                                                                                   Page 3
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                 In Process     Out




                FIGURE 1 - NEW WEB SERVICE PROJECT
                                           PROJ


           3.   In the New Web Service Project window:
                     a. Set the project name to Customer
                     b. Set Target Runtime to Oracle Weblogic Server 11gR1 PatchSet 3
                     c. Click Finish
           4.   Right-click in the Customer project and create a new folder called schemas
           5.   Create a new XML Schema CustomerType.xsd




                FIGURE 2 - NEW XML SCHEMA

                This schema will have the data structure the Web Service will use.

           6.   Copy and paste the following schema definition into the CustomerType.xsd file

                <schema xmlns="http://www.w3.org/2001/XMLSchema"
                               "http://www.w3.org/2001/XMLSchema"
                         targetNamespace="http://www.example.org/Customer"
                         targetNamespace
                         xmlns:tns="http://www.example.org/Customer"
                                     "http://www.example.org/Customer"
                         elementFormDefault="qualified">
                         elementFormDefault

                          <element name=
                                       ="customer" type="tns:CustomerType"></element>


An Oracle Technical Article                                                                          Page 4
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                 In Process     Out

                          <complexType name
                                        name="CustomerType">
                                    <sequence
                                     sequence>
                                              <element name="id" type="int"></element>
                                              <element name="firstname" type="string"></element>
                                              <element name="lastname" type="string"></element>
                                              <element name="address" type="tns:AddressType"></element
                                                                                                 element>
                                    </sequence
                                      sequence>
                          </complexType>>

                          <complexType name
                                        name="AddressType">
                          <sequence>
                                    <element name="street" type="string"></element>
                                     element
                                    <element name="country" type="string"></element>
                                     element
                                    <element name="city" type="string"></element>
                                     element
                          </sequence>
                  </complexType>
                </schema>


           7.   After pasting the content into CustomerType.xsd, right-click this file and select Generate > JAXB
                                                                          click
                Classes
                    a. Set Package field to com.oracle.examples.entities and click Finish.




                          FIGURE 3 - GENERATE JAVA CLASSE FROM XML SCHEMA USING JAXB
                                                   CLASSES                  ING

                     b.   The console will output the following results:

                                parsing a schema...
                                compiling a schema...
                                com/oracle/examples/entities/AddressType.java
                                com/oracle/examples/entities/CustomerType.java
                                com/oracle/examples/entities/ObjectFactory.java
                                com/oracle/examples/entities/package-info.java
                                com/oracle/examples/entities/package
                                com/oracle/examples/entities/jaxb.properties


           8.   Select Java Resources under Project Explorer tab and click in Weblogic Web Service to create a new
                                                                                   gic
                Web Service class.
                    a. In the New Web Service window set:
                              i. Package: com.oracle.examples.service
                             ii. Name: Customer

           9.   Copy the following code into the Customer.java class created

                package com.oracle.examples.service;

                import javax.jws.WebMethod;
                import javax.jws.WebService;
                import com.oracle.examples.entities.AddressType;
                import com.oracle.examples.entities.CustomerType;
                import com.oracle.examples.entities.ObjectFactory;

                @WebService
                public class Customer {


An Oracle Technical Article                                                                                 Page 5
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example

                       @WebMethod
                       public CustomerType getCustomer(int id) {

                                 ObjectFactory factory = new ObjectFactory();

                                 AddressType addressType = factory.createAddressType();
                                 CustomerType customerType = factory.createCustomerType();

                                 switch (id) {
                                 case 1:
                                             addressType.setCity("São Paulo");
                                             addressType.setCountry("BRA");
                                             addressType.setStreet("Marginal Pinheiros");

                                            customerType.setId(1);
                                            customerType.setFirstname("João");
                                            customerType.setLastname("Silva");
                                            customerType.setAddress(addressType);
                                            break;
                                 case 2:
                                            addressType.setCity("San Francisco");
                                            addressType.setCountry("USA");
                                            addressType.setStreet("Some address");

                                            customerType.setId(2);
                                            customerType.setFirstname("John");
                                            customerType.setLastname("Lock");
                                            customerType.setAddress(addressType);
                                            break;
                                 default:
                                               break;
                                 }
                                 // forcing slow down
                                 try {
                                               Thread.currentThread().sleep(9000);
                                 } catch (InterruptedException e) {
                                               // TODO Auto-generated catch block
                                               e.printStackTrace();
                                 }

                                 return customerType;
                       }
               }



               This Web Service will return fixed values but of course you should change this and do a real
               Customer search in a database using JPA and/or Oracle TopLink. Also, to simulate the slowness
               on our Web Service there is a Thread.sleep() call that will cause our service to return only after 9
               seconds.

           10. Deploy this project to a running instance of Weblogic Server and hit the URLs below to see the
               WSDL and test using Weblogic Test Client.


                WSDL URL           http://localhost:7001/Customer/CustomerService?WSDL

                TEST URL           http://localhost:7001/wls_utc/?wsdlUrl=http://localhost:70
                                   01/Customer/CustomerService?WSDL

               Note: You can deploy this project to same server you will be running Oracle Service Bus.

           11. When you invoke the service method getCustomer notice that it really takes 9 seconds to execute.




An Oracle Technical Article                                                                                 Page 6
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                 In Process     Out




                         FIGURE 4 - PROBLEMATIC WEB SERV
                                                    SERVICE RESPONSE



                         In the next section we will import the service into Oracle Service Bus and then learn
                         how service caching can reduce the impact of this performance problem.
                               ervice



ORACLE SERVICE BUS PROJECT
         In this section we will import the Web Service previously created and generate the Proxy and Business
Services in a Service Bus project. For more details about Proxy and Business services please check the following
link: http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/toc.htm

IMPORT WEB S ERVICE RESOURCES

            1.   Open Oracle Service Bus Console: http://localhost:7001/sbconsole
            2.   Click in Project Explorer, start a Session and create a new project. Name it Customer for example.
            3.   Click in the Customer project and look for the Create Resource combo box. Select Resources from
                 URL under Bulk.
            4.   Fill the form with the following information:
                      a. URL/Path: http://localhost:7001/Customer/CustomerService?WSDL
                      b. Resource Name: CustomerWSDL
                                    Name

An Oracle Technical Article                                                                                 Page 7
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                In Process     Out

                    c.   Resource Type: WSDL
                                  Type




                    FIGURE 5 - IMPORT WSDL RESOURCE INTO ORACLE SERVICE BUS

           5.   Click Next and then Import.

CREATE PROXY AND BUSINESS SERVICES

           1.   Click in the Customer project and look for Create Resource combo box. Select Business Service
                    a. Service Name CustomerBS
                                 Name:
                    b. Service Type: WSDL Web Service
                              i. In the Select WSDL window, select CustomerWSDL.
                             ii. Select CustomerPortBinding and Click Submit.
                    c. Keep the protocol as HTTP and in the Endpoint URI set
                         http://localhost:7001/Customer/CustomerService , which is the URL of the
                         http://localhost:7001/Customer/CustomerService
                         Web Service we created in the previous section.




An Oracle Technical Article                                                                            Page 8
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example




                    FIGURE 6 - BUSINESS SERVICE CREATION

                   d. Click Last and then Save.
           2.   Back to the Customer project, Create Resource combo box and now select Proxy Service
                   a. Service Name: CustomerPS
                   b. Service Type: Create From Existing Service
                              i. Select Business Service and point to CustomerBS.
                             ii. We don’t need to modify any settings in the Proxy Service, so you can click Last
                                 and then Save.

ACTIVATE AND TEST

           1.   Click Activate to save the changes done in this session and Submit.
           2.   Back to the Customer project, click in Launch Test Console under Actions column.
           3.   Now you can execute the Proxy Service and this will call our problematic Web Service. Since we
                hardcoded only two IDs, you can input only 1 or 2 to get some data in response. Other values
                will return an empty response document.




An Oracle Technical Article                                                                                 Page 9
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                               In Process     Out




               FIGURE 7 - REQUEST WITH PERFORMANCE PROBLEMS
                                       PERFORM




               FIGURE 8 - WEB SERVICE RESPONSE AFTER 9 SECONDS

               Note that all service calls is really taking around 9 seconds to execute. Sometimes it can take a
               little bit longer with an additional 1 or 2 seconds, but never less than 9 seconds since this is the
               “response time” of our backend Web Service.

               In the next section we will demonstrate how Oracle Service Bus and Oracle Coherence are
               integrated and how you can escalate the solution using an out
                                                                         out-of-process caching strategy.
                                                                                process


An Oracle Technical Article                                                                                Page 10
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example


ORACLE COHERENCE INTEGRATION
        Oracle Service Bus always had some mechanics of caching in order to provide XQuery and XML beans
caching also with object caching for Proxy and Business Services classes. But since release 11gR1, Oracle Service
Bus offered an integrated solution for result caching with Oracle Coherence.

        The result caching in Oracle Service Bus is available for Business Services. When you enable result
caching, the Business Service will not reach the back-end service and the response will come from the cache entry.
This entry can expire and if the entry is expired, the next service call will indeed reach the back-end service and
update the cache entry.




        FIGURE 9 - HOW RESULT CACHING WORKS

       For more details about how result caching works on Oracle Service Bus please check the following link
from Fusion Middleware 11g documentation:

      http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15867/configuringandus
ingservices.htm#OSBAG170

ACTIVATING CACHE FOR BUSINESS SERVICE

        To enable result caching for our Business Service follow these steps:

            1.   Click in Create at Change Center to create a new change session in Oracle Service Bus console.
            2.   Navigate to Customer project and click in the CustomerBS Business Service.
            3.   Click in Edit under Message Handling Configuration section.




An Oracle Technical Article                                                                                Page 11
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                In Process     Out




           FIGURE 10 - ENABLE BUSINESS SERVICE RESULT CACHE
                                       SERV

           4.   Expand Advanced Settings and in Result Caching select Supported.
           5.   Set the Cache Token Expression: fn:data($body/ser:getCustomer/arg0)
                                                                       :getCustomer/arg0)




           FIGURE 11 - BUSINESS SERVICE CAC
                                        CACHING SETTINGS

                This will use the customer ID as our unique token for the cache entry.
                                                              oken
                Also, set the Expiration Time for 10 minutes.

           6.   Click Last >> and Save to confirm the Business Service modifications. You can activate the
                change session.
           7.   Now click in Launch Test Console for CustomerPS proxy service and let’s test our configurations.
                The first time you execute the service, it takes 9 seconds to execute and it will populate our
                  he
                cache entry. Click Back in the Test Console and try to execute again. It will show the results
                immediately, directly from a cache entry in the embedded Oracle Coherence Server running
                within Oracle Service Bus. The cache Expiration Time (Time-to-Live) was set to 10 minutes in
                                                                                       )           1
                step 4, so during this period your calls will not hit the back
                                                                          back-end web service.




An Oracle Technical Article                                                                               Page 12
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example



        In this section we already provided one solution for our problematic service. But one can ask: What if I
want to see what’s going on with my cache? Other will say: How many entries do I have in my cache server?
And so on… Please check the next section for more details and a solution for development environments.

COHERENCE CONSOLE INTEGRATION WITH ORACLE SERVICE BUS CACHE

         Oracle Coherence offers good APIs for JMX and Reports about cache servers and that’s definitely the
way to go for monitoring production environments with huge loads. But for development environment and
other critical monitoring situations, you can use the Coherence Console.

          Coherence Console is a self-contained command line utility that connects to specific Coherence Servers.
It is a good tool to check which servers are participating in the cluster and let you browse the cache data. That’s
the tool we will be using in the example to monitor our cache entries and Coherence servers.

        In order to integrate Coherence Console and Oracle Service Cache you need to specify a few things:

            1.   Create a file named consoleOSB.sh and paste the following text:

                 #!/bin/sh
                 # Middleware home
                 MDW=/opt/oracle/osb11114
                 # Service Bus installation folder
                 OSB=$MDW/Oracle_OSB
                 # Domain home
                 DM=/opt/oracle/domains/osb11gR1
                 # ----------------------------------------------------------------------------

                 if [ -f $JAVA_HOME/bin/java ]; then
                    JAVAEXEC=$JAVA_HOME/bin/java
                 else
                    JAVAEXEC=java
                 fi

                 OPTS="-Xms64m -Xmx64m
                   -Dtangosol.coherence.override=$DM/config/osb/coherence/osb-coherence-
                 override.xml
                   -Dtangosol.coherence.cacheconfig=$DM/config/osb/coherence/osb-coherence-
                 cache-config.xml
                   -Dtangosol.coherence.distributed.localstorage=false
                   -Dtangosol.coherence.cluster=OSB-cluster
                   -Dtangosol.coherence.localhost=localhost
                   -DOSB.coherence.cluster=OSB-cluster"

                 CP="$MDW/oracle_common/modules/oracle.coherence_3.6/coherence.jar"
                 CP=$CP:"$MDW/modules/features/weblogic.server.modules.coherence.server_10.3.4.0
                 .jar"
                 CP=$CP:"$OSB/lib/osb-coherence-client.jar"
                 $JAVAEXEC -server -showversion $OPTS -cp $CP com.tangosol.net.CacheFactory $1

                 Note: You do not have to worry about the file location, you can place it anywhere.

            2.   Modify the script variables according to your installation settings. The variables are:
                    a. Middleware home - MDW
                    b. Oracle Service Bus installation directory - OSB
                    c. Domain Home - DM


An Oracle Technical Article                                                                                 Page 13
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example

           3.   Give the file execution permission and execute the script in a terminal. You should see an
                output similar to the following:

                markito@anakin:~/Projects/PTS$ ./consoleOSB.sh
                …
                2011-06-17 16:14:35.612/0.240 Oracle Coherence 3.6.0.4 <Info> (thread=main, member=n/a):
                Loaded operational configuration from
                "jar:file:/opt/oracle/osb11114/oracle_common/modules/oracle.coherence_3.6/coherence.jar!
                /tangosol-coherence.xml"
                2011-06-17 16:14:35.621/0.249 Oracle Coherence 3.6.0.4 <Info> (thread=main, member=n/a):
                Loaded operational overrides from
                "file:/opt/oracle/domains/osb11gR1/config/osb/coherence/osb-coherence-override.xml"
                2011-06-17 16:14:35.629/0.257 Oracle Coherence 3.6.0.4 <D5> (thread=main, member=n/a):
                Optional configuration override "/custom-mbeans.xml" is not specified
                Oracle Coherence Version 3.6.0.4 Build 19111
                Grid Edition: Development mode
                Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
                2011-06-17 16:14:36.127/0.755 Oracle Coherence GE 3.6.0.4 <Warning> (thread=main,
                member=n/a): Local address "127.0.0.1" is a loopback address; this cluster node will not
                connect to nodes located on different machines
                2011-06-17 16:14:36.136/0.764 Oracle Coherence GE 3.6.0.4 <D4> (thread=main,
                member=n/a): TCMP bound to /127.0.0.1:7892 using SystemSocketProvider
                2011-06-17 16:14:36.445/1.073 Oracle Coherence GE 3.6.0.4 <Info> (thread=Cluster,
                member=n/a): This Member(Id=4, Timestamp=2011-06-17 16:14:36.262,
                Address=127.0.0.1:7892, MachineId=26733,
                Location=site:localdomain,machine:localhost,process:13130, Role=CoherenceConsole,
                Edition=Grid Edition, Mode=Development, CpuCount=4, SocketCount=2) joined cluster "OSB-
                cluster" with senior Member(Id=1, Timestamp=2011-06-17 11:00:46.772,
                Address=127.0.0.1:7890, MachineId=26733,
                Location=site:localdomain,machine:localhost,process:5603, Role=OSB-node, Edition=Grid
                Edition, Mode=Development, CpuCount=4, SocketCount=2)
                2011-06-17 16:14:36.454/1.082 Oracle Coherence GE 3.6.0.4 <D5> (thread=Cluster,
                member=n/a): Member 1 joined Service Cluster with senior member 1
                2011-06-17 16:14:36.454/1.082 Oracle Coherence GE 3.6.0.4 <D5> (thread=Cluster,
                member=n/a): Member 1 joined Service Management with senior member 1
                2011-06-17 16:14:36.454/1.082 Oracle Coherence GE 3.6.0.4 <D5> (thread=Cluster,
                member=n/a): Member 1 joined Service ORA-OSB-deployments with senior member 1
                2011-06-17 16:14:36.457/1.085 Oracle Coherence GE 3.6.0.4 <Info> (thread=main,
                member=n/a): Started cluster Name=OSB-cluster
                WellKnownAddressList(Size=2,
                  WKA{Address=127.0.0.1, Port=9999}
                  WKA{Address=127.0.0.1, Port=7890}
                  )
                MasterMemberSet
                  (
                  ThisMember=Member(Id=4, Timestamp=2011-06-17 16:14:36.262, Address=127.0.0.1:7892,
                MachineId=26733, Location=site:localdomain,machine:localhost,process:13130,
                Role=CoherenceConsole)
                  OldestMember=Member(Id=1, Timestamp=2011-06-17 11:00:46.772, Address=127.0.0.1:7890,
                MachineId=26733, Location=site:localdomain,machine:localhost,process:5603, Role=OSB-
                node)
                  ActualMemberSet=MemberSet(Size=2, BitSetCount=2
                    Member(Id=1, Timestamp=2011-06-17 11:00:46.772, Address=127.0.0.1:7890,
                MachineId=26733, Location=site:localdomain,machine:localhost,process:5603, Role=OSB-
                node)
                    Member(Id=4, Timestamp=2011-06-17 16:14:36.262, Address=127.0.0.1:7892,
                MachineId=26733, Location=site:localdomain,machine:localhost,process:13130,
                Role=CoherenceConsole)
                    )
                  RecycleMillis=1200000
                  RecycleSet=MemberSet(Size=0, BitSetCount=0
                    )
                  )
                TcpRing{Connections=[1]}
                IpMonitor{AddressListSize=0}
                2011-06-17 16:14:36.500/1.128 Oracle Coherence GE 3.6.0.4 <D5>
                (thread=Invocation:Management, member=4): Service Management joined the cluster with
                senior service member 1

                Map (?):




An Oracle Technical Article                                                                              Page 14
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example

           4.   Now you are already connected to the same Oracle Coherence cluster with Oracle Service Bus.
                There are various commands available for Coherence Console, please check the documentation
                for a complete list. Let’s check our cache entries:
                     a. Type cache /osb/service/ResultCache and hit enter:

                Map (?): cache /osb/service/ResultCache
                2011-06-17 16:27:25.807/770.435 Oracle Coherence GE 3.6.0.4 <Info> (thread=main,
                member=4): Loaded cache configuration from
                "file:/opt/oracle/domains/osb11gR1/config/osb/coherence/osb-coherence-cache-
                config.xml"
                2011-06-17 16:27:26.352/770.980 Oracle Coherence GE 3.6.0.4 <D5>
                (thread=DistributedCache:ORA-OSB-deployments, member=4): Service ORA-OSB-
                deployments joined the cluster with senior service member 1
                <distributed-scheme>
                  <scheme-name>expiring-distributed</scheme-name>
                  <service-name>ORA-OSB-deployments</service-name>
                  <backing-map-scheme>
                    <local-scheme>
                      <scheme-ref>expiring-backing-map</scheme-ref>
                    </local-scheme>
                  </backing-map-scheme>
                  <autostart>true</autostart>
                </distributed-scheme>


                    b.   Type list or size commands and you should see no results if you are following our
                         example. That’s because our entries expired (10 minutes, remember?) and we now must
                         execute the Proxy Service CustomerPS again to populate our cache server entries. If your
                         cache is still valid (not expired) you will get different results and of course your entry
                         will be already there.

           5.   Get back to the Service Bus console, Launch the Test Client again and execute CustomerPS.
           6.   Go to the Coherence Console and type list or size commands. You should see the following
                output (before and after testing):

                Map (/osb/service/ResultCache): list
                Map (/osb/service/ResultCache): size
                0
                Map (/osb/service/ResultCache): size
                1
                Map (/osb/service/ResultCache): list
                PipelineResultCacheKey[BusinessService Customer/CustomerBS,getCustomer,1) =
                owner=BusinessService Customer/CustomerBS,value=[B@58c16b18


           7.   Go back to the Service Bus Test client and try to execute with a different Customer ID that you
                used in the previous execution. You should see 2 entries and after 10 minutes, they will expire.

CREATING A NEW EXTERNAL COHERENCE SERVER FROM WEBLOGIC CONSOLE

        Now that we already have our service cache enabled, we will have a better throughput performance and
can attend much more users in our system. That is true but remembers we are still using an in-process strategy
and this means that we are using the same JVM memory for cache entries, Weblogic services like JDBC or JMS,
and Oracle Service Bus objects, like transformations, Proxy Services and Business Services. If we increase our
cache usage to a high volume, we can go out of memory easily and compromise all other services in the
Enterprise Service Bus, even the ones that are not using cache features, in a worst case scenario.




An Oracle Technical Article                                                                                Page 15
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                 In Process     Out

       To solve this situation you can use an external Coherence Server. That will be a dedicated JVM with its
own Coherence Server. This solution can increase the scalability of our overall architecture and a more complex
Coherence Cluster infrastructure can take in place. It is out of the scope of this article discuss the configuration
                    frastructure
of Coherence Clusters, but it will give an idea of what can be achieved and then adjusted for your situation.

        These are the steps to add a new Coherence server using Weblogic Console:

            1.   Log into Weblogic console: http://localhost:7001/console
            2.   If you are running a domain without a Machine associated in Weblogic, you have to add a
                 machine and associate the Coherence Server with this Machine. Expand Environment in the left
                 menu and select Machines
                                  Machines.
            3.   Fill up the New Machine form with the following information:
                      a. Name: anakin [replace with your machine name]
                      b. Machine OS: Unix [replace with your OS]
                      c. Click Next




                    FIGURE 12 - ADDING A NEW MACHINE

            4.   In the Node Manager Properties form use the following information:
                           e
                      a. Type: Plain [change it to SSL or SSH for production environments]
                                      change
                      b. Listen Address: localhost
                      c. Listen Port: 5556
                      d. Click Finish




                    FIGURE 13 - NODE MANAGER PROPERT
                                             PROPERTIES

An Oracle Technical Article                                                                                 Page 16
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                In Process     Out

                Later we will setup the node manager scripts to complete this step.

           5.   Expand Environment select Coherence Servers in the left menu and click in New
                         Environment,
           6.   Fill up this form with the following information:
                     a. Name: server1
                     b. Machine: anakin [or replace with the machine name used in step 3]
                                           or                                              3
                     c. Unicast Listen Address: localhost
                     d. Unicast Listen Port: 9999
                     e. Click Finish
                                Finish.




                    FIGURE 14 – CREATING A NEW COHERENCE SERVER
                                               COHER

           7.   In the Coherence servers screen, click in server1. We need to adjust the class path of this server to
                                    ervers
                integrate with Oracle Service Bus.
           8.   In the Settings for server1 screen, click in Server Start tab and fill the following fields:
                     a. Java Home: /opt/oracle/jrockit-jdk1.6.0_20-R28.1.0-4.0.1        4.0.1
                         [set to your java home location]
                          set                      location

                    b.   BEA Home: /opt/oracle/osb11114/
                         [set to your Oracle Service Bus installation directory]

                    c.   Class Path:
                         /opt/oracle/osb11114/modules/features/weblogic.server.modules.coherence.server_10
                         .3.4.0.jar:/opt/oracle/osb11114/coherence_3.6/lib/coherence.jar:/opt/oracle/osb11
                         114/Oracle_OSB/lib/osb-coherence-client.jar
                         114/Oracle_OSB/lib/osb
                         [replace /opt/oracle/osb11114/ with your Oracle Service Bus installation directory]
                                                                           rvice                  directory

                    d. Arguments:
                         -
                         Dtangosol.coherence.override=/opt/oracle/domains/osb11gR1/
                         Dtangosol.coherence.override=            domains/osb11gR1/config/osb/coherence/os
                         b-coherence
                           coherence-override.xml
                          -
                         Dtangosol.coherence.cacheconfig=/opt/oracle/domains/osb11gR1/
                         Dtangosol.coherence.cacheconfig=            domains/osb11gR1/config/osb/coherence
                         /osb-coherence
                              coherence-cache-config.xml
                          -Dtangosol.coherence.distributed.localstorage=true
                           Dtangosol.coherence.distributed.localstorage=true
                          -Dtangosol.coherence.cluster=OSB
                           Dtangosol.coherence.cluster=OSB-cluster
                          -Dtangosol.coherence.localhost=localhost
                           Dtangosol.coherence.localhost=localhost
                          -DOSB.coherence.cluster=OSB
                           DOSB.coherence.cluster=OSB-cluster
                         [replace /opt/domains/osb11gR1/ with your Oracle Service Bus domain directory]
An Oracle Technical Article                                                                                 Page 17
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                In Process     Out


                         Note: In order to use this Coherence server as storage node the
                         tangosol.coherence.distributed.localstorage property needs to be true.

                    e.   Click Save.




                    FIGURE 15 - COHERENCE SERVER SETTINGS
                                                 SET

           9.   Now we need to add our new server to the WKA (Well Known Address) list of Coherence
                Servers in the Oracle Service Bus configuration.
                    a. In the command terminal, browse to
                        /opt/oracle/domains/osb11gR1/config/osb/coherence
                    b. Edit the osb--coherence-override.xml file and update according the following snippet:
                         <!DOCTYPE coherence SYSTEM "coherence.dtd">
                         <coherence>
                             <cluster--config>
                                 <!--
                                      By specifying a well
                                                       well-known-address we disable the mutlicast listener.
                                                                  address
                                      This ensures that the Coherence cluster for OSB will be isolated to this machine
                         only.
                                 -->
                                        <unicast-listener>
                                                 <well-known-addresses>
                                        <socket-address id="1">
                                               <address system-property="OSB.coherence.wka1">127.0.0.1</address>
                                                               property="OSB.coherence.wka1">127.0.0.1</address>
                                               <port system-property="OSB.coherence.wka1.port">7890</port>
                                                            property="OSB.coherence.wka1.port">7890</port>
                                          </socket-address>

                                         <socket-address id="2">
                                             <address system-property="OSB.coherence.wka2">127.0.0.1</address>
                                                              property="OSB.coherence.wka2">127.0.0.1</address>
                                             <port system-property="OSB.coherence.wka2.port">9999</port>
                                                           property="OSB.coherence.wka2.port">9999</port>
                                         </socket-address>

                                                  </well-known-addresses>
                                      <address system
                                               system-property="OSB.coherence.localhost">127.0.0.1</address>
                                                                     oherence.localhost">127.0.0.1</address>
                                      <port system-property="OSB.coherence.localport">7890</port>
                                            system property="OSB.coherence.localport">7890</port>
                                          </unicast-listener>
                                          <multicast-listener>
                                                  <time-to-live system-property="OSB.coherence.tt
                                                                       property="OSB.coherence.ttl">0</time-to-live>
                                          </multicast-listener>
                                 </cluster-config>
                                 </cluster
                         </coherence>


                         Here we are adding a new socket address to the Oracle Coherence cluster. For security
                         and performance reasons, Oracle Coherence server that is bundled with Oracle Service

An Oracle Technical Article                                                                                   Page 18
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example

                          Bus uses WKA and Unicast, so for every new node you add to the cluster this file needs
                          to be updated or make sure that at least one of the nodes specified here is running when
                          trying to start other nodes unlisted. In this case, we are specifying a new server listening
                          in the localhost address (127.0.0.1) and port 9999.
                     c.   Save and close osb-coherence-override.xml.

                 Note: You can also perform the same configuration shown in this step (step 9) through adding
                 two more properties in the Coherence server configuration in Weblogic Console:

                            -DOSB.coherence.wka2=localhost
                            -DOSB.coherence.wka2.port=9999

            10. Now it is time to test all we have done so far, please do the following:
                   a. Shutdown Oracle Service Bus domain.
                   b. In a command terminal, browse to
                        /opt/oracle/osb11114/wlserver_10.3/server/bin where
                        /opt/oracle/osb11114/ is your Oracle Service Bus installation directory.
                   c. Execute the script to start the node manager:

                          ./startNodeManager.sh

                     d.   Start your Oracle Service Bus domain.
                     e.   Go to the Weblogic Server console: http://localhost:7001/console
                     f.   Expand Environment in the menu on the left and click in Coherence Servers.
                     g.   Click in Control tab, mark server1 and click in Start.
                     h.   Note that the State column value changed to Starting and after a few seconds to
                          Running.

                 Congratulations, you have a new Coherence Server up and running integrated with Oracle
                 Service Bus and can manage your server through Weblogic Console with the help of a Node
                 Manager. In the next sections we will test this integration and play with our cache server.



OUT-OF -PROCESS CACHING WITH EXTERNAL COHERENCE SERVER

        Now it is time to test our out-of-process strategy caching and execute our problematic web service
again. Remember that we still have both servers able to store cached data, the internal server bundled with
Oracle Service Bus and the external server1 because they have tangosol.coherence.distributed.localstorage
property set to true.

        To test your out-of-process cache you can do the following:

            1.   Open a command terminal and browse to the consoleOSB.sh script that we created before.
                 Execute. You should see the following output:

                 ………
                 …
                 WellKnownAddressList(Size=2,
                   WKA{Address=127.0.0.1, Port=7890}
                   WKA{Address=127.0.0.1, Port=9999}

An Oracle Technical Article                                                                                   Page 19
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example

                   )
                 MasterMemberSet
                   (
                   ThisMember=Member(Id=3, Timestamp=2011-06-20 15:03:22.947, Address=127.0.0.1:7894,
                 MachineId=8417, Location=site:localdomain,machine:localhost,process:11912,
                 Role=CoherenceConsole)
                   OldestMember=Member(Id=1, Timestamp=2011-06-20 14:34:49.401, Address=127.0.0.1:7890,
                 MachineId=8417, Location=site:localdomain,machine:localhost,process:10716, Role=OSB-
                 node)
                   ActualMemberSet=MemberSet(Size=3, BitSetCount=2
                     Member(Id=1, Timestamp=2011-06-20 14:34:49.401, Address=127.0.0.1:7890,
                 MachineId=8417, Location=site:localdomain,machine:localhost,process:10716, Role=OSB-
                 node)
                     Member(Id=2, Timestamp=2011-06-20 14:47:55.749, Address=127.0.0.1:7892,
                 MachineId=8417,
                 Location=site:localdomain,machine:localhost,process:11562,member:server1,
                 Role=WeblogicWeblogicCacheServer)
                     Member(Id=3, Timestamp=2011-06-20 15:03:22.947, Address=127.0.0.1:7894,
                 MachineId=8417, Location=site:localdomain,machine:localhost,process:11912,
                 Role=CoherenceConsole)
                     )
                   RecycleMillis=1200000
                   RecycleSet=MemberSet(Size=0, BitSetCount=0
                     )
                   )
                 TcpRing{Connections=[2]}
                 IpMonitor{AddressListSize=0}


                 Note that you have now two address in the Well Know Address List and three members in the
                 Coherence cluster: OSB-node (internal), server1 (external) and CoherenceConsole (which is the
                 console we are using).
            2.   In the Oracle Coherence Console, enter in Oracle Service Bus ResultCache:

                 Map (?): cache /osb/service/ResultCache


            3.   In the web browser, log in Oracle Service Bus console:
                 http://localhost:7001/sbconsole

            4.   Click in Project Explorer, browse to Customer project and Launch Test Console for CustomerPS
                 proxy service.
            5.   Execute the service and you should experience the 9 seconds execution time for the first call.
                 Click Back, execute again and your result should be immediate, just like we did previously.
            6.   Type size or list in the Coherence console and you will see one entry.
            7.   To validate our external cache server and check if it is working, shutdown Oracle Service Bus
                 domain.
            8.   Type size or list again in the Coherence console and you should still see one entry. That’s
                 it! The external Coherence Server is holding our data for 10 minutes.
            9.   Start Oracle Service Bus domain, log in sbconsole and re-execute CustomerPS proxy service.
                 You will see an immediate response because the data is still coming from the cache and not the
                 back-end service.

                 Note: Remember to use the same customer ID attempted in step 5, otherwise your call will hit
                 the back-end service.

SET INTERNAL COHERENCE SERVER STORAGE TO FALSE
       As we can see in the previous section the external Coherence server (server1) is already taking care of
cached data storage. But we are still doing cache in both Coherence servers, internal and external, and for a
production environment it may be a good idea to disable the storage of internal Coherence server and free some

An Oracle Technical Article                                                                             Page 20
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example

JVM memory that can be used for other services like JDBC, JMS or service processing. With this change all
cached data will be stored only in the external Coherence server (server1).

        To execute these settings follow the steps below:

            1.   Make sure you have the external Oracle Coherence (server1) already running with storage
                 enabled. Otherwise you will see many exceptions in Oracle Service Bus logs complaining that
                 Service Result Caching functionality is disabled. This happens because there will be no cache
                 servers with storage enabled in the Coherence Cluster and because of that caching will not be
                 possible.
            2.   Open a command terminal and browse to the Oracle Service Bus domain directory.
            3.   Open /opt/oracle/domains/osb11gR1/bin/startDomainEnv.sh in a text editor and
                 look for the following line:

                 JAVA_OPTIONS="${JAVA_OPTIONS} ${JAVA_PROPERTIES}
                 -Dwlw.iterativeDev=${iterativeDevFlag} -Dwlw.testConsole=${testConsoleFlag}
                 -Dwlw.logErrorsToConsole=${logErrorsToConsoleFlag} "


            4.   Modify this line to look like the one below:

                 JAVA_OPTIONS="${JAVA_OPTIONS} ${JAVA_PROPERTIES} -Dwlw.iterativeDev=${iterativeDevFlag}
                 -Dwlw.testConsole=${testConsoleFlag} -Dwlw.logErrorsToConsole=${logErrorsToConsoleFlag}
                 -Dtangosol.coherence.distributed.localstorage=false "


            5.   Save and close the startDomainEnv.sh file.
            6.   Restart your Oracle Service Bus domain to apply the changes.
            7.   Once your server is starting, look for the line we modified in step 3 in the starting information
                 that Weblogic outputs.

                 /opt/oracle/jrockit-jdk1.6.0_20-R28.1.0-4.0.1/bin/java -jrockit -Xdebug -Xnoagent -
                 Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n -Djava.compiler=NONE -
                 Xms648m -Xmx768m -Dweblogic.Name=AdminServer -
                 Djava.security.policy=/opt/oracle/osb11114/wlserver_10.3/server/lib/weblogic.policy -
                 Xverify:none -da:org.apache.xmlbeans...   -ea -da:com.bea... -da:javelin... -
                 da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole... -
                 Dplatform.home=/opt/oracle/osb11114/wlserver_10.3 -
                 Dwls.home=/opt/oracle/osb11114/wlserver_10.3/server -
                 Dweblogic.home=/opt/oracle/osb11114/wlserver_10.3/server -
                 Dcommon.components.home=/opt/oracle/osb11114/oracle_common -Djrf.version=11.1.1 -
                 Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -
                 Ddomain.home=/opt/oracle/domains/osb11gR1 -
                 Djrockit.optfile=/opt/oracle/osb11114/oracle_common/modules/oracle.jrf_11.1.1/jrocket_op
                 tfile.txt -
                 Doracle.server.config.dir=/opt/oracle/domains/osb11gR1/config/fmwconfig/servers/AdminSer
                 ver -Doracle.domain.config.dir=/opt/oracle/domains/osb11gR1/config/fmwconfig -
                 Digf.arisidbeans.carmlloc=/opt/oracle/domains/osb11gR1/config/fmwconfig/carml -
                 Digf.arisidstack.home=/opt/oracle/domains/osb11gR1/config/fmwconfig/arisidprovider -
                 Doracle.security.jps.config=/opt/oracle/domains/osb11gR1/config/fmwconfig/jps-config.xml
                 -Doracle.deployed.app.dir=/opt/oracle/domains/osb11gR1/servers/AdminServer/tmp/_WL_user
                 -Doracle.deployed.app.ext=/- -
                 Dweblogic.alternateTypesDirectory=/opt/oracle/osb11114/oracle_common/modules/oracle.osso
                 iap_11.1.1,/opt/oracle/osb11114/oracle_common/modules/oracle.oamprovider_11.1.1 -
                 Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dweblogic.jdbc.remoteEnabled=false
                 -Dem.oracle.home=/opt/oracle/osb11114/oracle_common -Djava.awt.headless=true -
                 Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= -
                 Dwlw.logErrorsToConsole= -Dtangosol.coherence.distributed.localstorage=false -
                 Dweblogic.ext.dirs=/opt/oracle/osb11114/patch_wls1034/profiles/default/sysext_manifest_c
                 lasspath:/opt/oracle/osb11114/patch_ocp360/profiles/default/sysext_manifest_classpath
                 weblogic.Server



            8.   Now execute the CustomerPS proxy service.


An Oracle Technical Article                                                                                 Page 21
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example
                                                                In Process     Out

           9.   Back to the command terminal, execute the consoleOSB.sh (Coherence Console) and type size
                                    nd
                or list commands. You should still see one entry in the cache but now it is stored only in the
                external Coherence server (server1) and the Oracle Service Bus internal Coherence server is now
                                            (     )
                acting as client node only.


CONCLUSION
       In this article was presented two different cache strategies and the benefits of using out-of-process
                                                                                              out
caching with Oracle Coherence and Oracle Service Bus. There was an example of a Web Service with
performance problems exposed in Oracle Service Bus and through the use of result caching the response time
           e
improvement is clear.

        Also the Oracle Coherence Console integration with Oracle Service Bus is an alternative for
development and troubleshooting of service caching solutions capable to show the running servers and cached
                                           caching
data information.

         Out-of-process caching can drastically reduce the JVM memory footprint of an Oracle Service Bus
                process
domain and increase the scalability and fail
                                         fail-over of the architecture and it is a recommended approach for
projects that needs to scale safely.


REFERENCES
                              Link                                                    Description
http://download.oracle.com/docs/cd/E21764_01/doc.1111/e1586       Documentation about Result Cache in Oracle Service
7/configuringandusingservices.htm#OSBAG170                        Bus
http://coherence.oracle.com/display/COH/Oracle+Coherence+Kn
      /coherence.oracle.com/display/COH/Oracle+Coherence+Kn       Coherence Knowledge Base with documentation,
owledge+Base+Home                                                 Screencasts and examples
http://mazanatti.info/index.php?/archives/65
 ttp://mazanatti.info/index.php?/archives/65-Connecting-a-        Script that connects to Oracle Coherence console and
console-to-an-OSB-Coherence-cluster.html
                            cluster.html                          Oracle Service Bus
http://www.oracle.com/technetwork/middleware/service-
http://www.oracle.com/technetwork/middleware/service              Oracle Service Bus documentation index
bus/documentation/index.html




ABOUT THE AUTHOR

                               William Markito Oliveira is a Senior Technologist at Oracle Platform Technology
                               Solutions team in Brazil where he focuses in Middleware, SOA and Java
                                                                                  Middleware
                               technologies. Work also as contributor to the official Java EE 6 Tutorial
                               providing write ups and code examples about CDI, EJB 3.1 and JAX-RS. Has
                                         write-ups
                               more than 8 years of experience in Software Development, Consulting and
                               Architecture, previously working as a Solution Architect in several companies.




An Oracle Technical Article                                                                                     Page 22
Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example




An Oracle Technical Article                                                                       Page 23

More Related Content

What's hot (20)

PPTX
Marco civil-da-internet
Denis Luiz
 
PPTX
MongoDB Evenings Chicago - WindyGrid: Utilizing MongoDB for a Smarter & Safer...
MongoDB
 
PDF
Apache Airflow 概要(Airflowの基礎を学ぶハンズオンワークショップ 発表資料)
NTT DATA Technology & Innovation
 
PDF
DSC 再入門
Kazuki Takai
 
PDF
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
Amazon Web Services Japan
 
PDF
Oficina "A aplicação do ICA-AtoM na descrição e difusão arquivística - Instal...
Dhion C. Hedlund
 
PPTX
Segurança da informação - Aula 3 - Ciclo de vida, classificação de ativos
Cleber Fonseca
 
PDF
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
Amazon Web Services Japan
 
PDF
20180724 AWS Black Belt Online Seminar Amazon Elastic Container Service for K...
Amazon Web Services Japan
 
PDF
Portlet Specification 3.0 Is Here!
Dev_Events
 
PPTX
2024: 50 graphics I posted on X, LinkedIn and/or Bluesky
HelenBevan4
 
PDF
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
Frederic Descamps
 
PDF
RDBNoSQLの基礎と組み合わせDB構成をちょっとよくする話
Shohei Kobayashi
 
PDF
Web Application Forensics: Taxonomy and Trends
Krassen Deltchev
 
PDF
Azure上の データベース 機能の選び方。KVSからDWHまで
Daisuke Masubuchi
 
PDF
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
Amazon Web Services Korea
 
PDF
RHEL7/CentOS7 NetworkManager徹底入門
Etsuji Nakai
 
PDF
대용량 데이터레이크 마이그레이션 사례 공유 [카카오게임즈 - 레벨 200] - 조은희, 팀장, 카카오게임즈 ::: Games on AWS ...
Amazon Web Services Korea
 
PPTX
fetch APIを安全に使う方法をおさらいしてみよう
iPride Co., Ltd.
 
PPTX
Apache Spark 2.4 and 3.0 What's Next?
NTT DATA Technology & Innovation
 
Marco civil-da-internet
Denis Luiz
 
MongoDB Evenings Chicago - WindyGrid: Utilizing MongoDB for a Smarter & Safer...
MongoDB
 
Apache Airflow 概要(Airflowの基礎を学ぶハンズオンワークショップ 発表資料)
NTT DATA Technology & Innovation
 
DSC 再入門
Kazuki Takai
 
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
Amazon Web Services Japan
 
Oficina "A aplicação do ICA-AtoM na descrição e difusão arquivística - Instal...
Dhion C. Hedlund
 
Segurança da informação - Aula 3 - Ciclo de vida, classificação de ativos
Cleber Fonseca
 
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
Amazon Web Services Japan
 
20180724 AWS Black Belt Online Seminar Amazon Elastic Container Service for K...
Amazon Web Services Japan
 
Portlet Specification 3.0 Is Here!
Dev_Events
 
2024: 50 graphics I posted on X, LinkedIn and/or Bluesky
HelenBevan4
 
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
Frederic Descamps
 
RDBNoSQLの基礎と組み合わせDB構成をちょっとよくする話
Shohei Kobayashi
 
Web Application Forensics: Taxonomy and Trends
Krassen Deltchev
 
Azure上の データベース 機能の選び方。KVSからDWHまで
Daisuke Masubuchi
 
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
Amazon Web Services Korea
 
RHEL7/CentOS7 NetworkManager徹底入門
Etsuji Nakai
 
대용량 데이터레이크 마이그레이션 사례 공유 [카카오게임즈 - 레벨 200] - 조은희, 팀장, 카카오게임즈 ::: Games on AWS ...
Amazon Web Services Korea
 
fetch APIを安全に使う方法をおさらいしてみよう
iPride Co., Ltd.
 
Apache Spark 2.4 and 3.0 What's Next?
NTT DATA Technology & Innovation
 

Similar to Oracle Service Bus & Coherence Caching Strategies (20)

PPTX
Managing Oracle Fusion Middleware
Fumiko Yamashita
 
PDF
Osb developer's guide
Harish B
 
PDF
Server Day 2009: Oracle/Bea Fusion Middleware by Paolo Ramasso
JUG Genova
 
PPTX
Oracle SOA Suite 12.2.1 new features
Maarten Smeets
 
DOC
Ibm integration bus
FuturePoint Technologies
 
PPTX
oracle ebs free web service integration tools
SmartDog Services
 
PDF
Report from the trenches: Using SOA Integrated Gateway
Lonneke Dikmans
 
PDF
F428435966 odtug web-logic for developers
Meng He
 
PDF
UK OUG - Oracle Fusion Middleware in Irish Life Invesment Managers
guest93167ee
 
PDF
UK OUG - Oracle Fusion Middleware in Irish Life Invesment Managers
Arnaud Benjacar
 
PDF
UK OUG - Oracle Fusion Middleware in Irish Life Invesment Managers
guest93167ee
 
PDF
Soa suite12c presentation @AMIS by Simone Geib
Getting value from IoT, Integration and Data Analytics
 
PPTX
componenets of osb12c
TUSHAR VARSHNEY
 
PDF
OOW09 Integration Architecture EBS R12
jucaab
 
PDF
Oracle OSB Tutorial 1
Rakesh Gujjarlapudi
 
PPTX
Componenets of osb12c
TUSHAR VARSHNEY
 
PPTX
Web Services.pptx
ShaikRasool27
 
PDF
SOA_BPM_12c_launch_event_SOA_track_deepdive_developerproductivityandperforman...
Getting value from IoT, Integration and Data Analytics
 
PPT
Web Services Best Practices 072604.ppt
mercurial02
 
PDF
Preparing for EBS R12.2-upgrade-full
Berry Clemens
 
Managing Oracle Fusion Middleware
Fumiko Yamashita
 
Osb developer's guide
Harish B
 
Server Day 2009: Oracle/Bea Fusion Middleware by Paolo Ramasso
JUG Genova
 
Oracle SOA Suite 12.2.1 new features
Maarten Smeets
 
Ibm integration bus
FuturePoint Technologies
 
oracle ebs free web service integration tools
SmartDog Services
 
Report from the trenches: Using SOA Integrated Gateway
Lonneke Dikmans
 
F428435966 odtug web-logic for developers
Meng He
 
UK OUG - Oracle Fusion Middleware in Irish Life Invesment Managers
guest93167ee
 
UK OUG - Oracle Fusion Middleware in Irish Life Invesment Managers
Arnaud Benjacar
 
UK OUG - Oracle Fusion Middleware in Irish Life Invesment Managers
guest93167ee
 
Soa suite12c presentation @AMIS by Simone Geib
Getting value from IoT, Integration and Data Analytics
 
componenets of osb12c
TUSHAR VARSHNEY
 
OOW09 Integration Architecture EBS R12
jucaab
 
Oracle OSB Tutorial 1
Rakesh Gujjarlapudi
 
Componenets of osb12c
TUSHAR VARSHNEY
 
Web Services.pptx
ShaikRasool27
 
SOA_BPM_12c_launch_event_SOA_track_deepdive_developerproductivityandperforman...
Getting value from IoT, Integration and Data Analytics
 
Web Services Best Practices 072604.ppt
mercurial02
 
Preparing for EBS R12.2-upgrade-full
Berry Clemens
 
Ad

Oracle Service Bus & Coherence Caching Strategies

  • 1. An Oracle Technical Article July 11 ORACLE SERVICE BUS AND ORACLE COHERENCE: AN IN-PROCESS AND OUT- OF-PROCESS CACHE EXAMPLE by William Markito Oliveira Senior Technologist Platform Technology Services
  • 2. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example TABLE OF CONTENTS Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example ................................. 1 Introduction ......................................................................................................................................................................... 3 Requirements................................................................................................................................................................... 3 Our Problematic Web Service ........................................................................................................................................... 3 Web Service Project ........................................................................................................................................................ 3 Oracle Service Bus Project.................................................................................................................................................. 7 Import Web Service Resources ..................................................................................................................................... 7 Create Proxy and Business Services ............................................................................................................................. 8 Activate and Test ............................................................................................................................................................ 9 Oracle Coherence Integration ......................................................................................................................................... 11 Activating Cache for Business Service ....................................................................................................................... 11 Coherence console integration with Oracle Service Bus Cache.............................................................................. 13 Creating a new external coherence server from Weblogic console........................................................................ 15 Out-of-process caching with external Coherence server ......................................................................................... 19 Set internal Coherence server Storage to False ......................................................................................................... 20 Conclusion ......................................................................................................................................................................... 22 References .......................................................................................................................................................................... 22 About the Author .............................................................................................................................................................. 22 TABLE OF FIGURES Figure 1 - New Web Service Project ..................................................................................................................................... 4 Figure 2 - New XML Schema ................................................................................................................................................ 4 Figure 3 - Generate Java Classes from XML Schema using JAXB .................................................................................... 5 Figure 4 - Problematic Web Service Response .................................................................................................................... 7 Figure 5 - Import WSDL Resource into Oracle Service BUS ............................................................................................. 8 Figure 6 - Business Service Creation .................................................................................................................................... 9 Figure 7 - Request With Performance Problems............................................................................................................... 10 Figure 8 - Web Service RESPONSE After 9 seconds ........................................................................................................ 10 Figure 9 - How Result Caching Works .............................................................................................................................. 11 Figure 10 - Enable Business Service Result Cache ............................................................................................................ 12 Figure 11 - Business Service Caching Settings .................................................................................................................. 12 Figure 12 - Adding a New machine ................................................................................................................................... 16 Figure 13 - Node Manager Properties ................................................................................................................................ 16 Figure 14 – Creating a New Coherence Server ................................................................................................................. 17 Figure 15 - Coherence Server Settings................................................................................................................................ 18 An Oracle Technical Article Page 2
  • 3. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example INTRODUCTION Since version 11g Oracle Service Bus provides a built-in cache functionality that features Oracle Coherence offering a first class support for many caching strategies. This article describes how to use these functionalities and explore a fail-over scenario with an example of how caching strategies can speed up your Web Services and even prevent production outages. REQUIREMENTS Software Version Description Oracle Service Bus 11.1.1.4 Enterprise Service Bus- Oracle Coherence 3.6 Data Grid Cache Server Weblogic Server 10.3.4 Application Server Linux or Windows N/A Operating System Oracle Enterprise Pack for Eclipse (OEPE) 3.6 IDE This article is written considering the reader already has knowledge in the following areas: • Java and Web Services • Basic Oracle Service Bus Knowledge • Basic Weblogic Server Administration • Has one Oracle Service Bus domain up and running. OUR PROBLEMATIC WEB SERVICE In our case study, we have a simple Web Service called CustomerService that is currently with some performance problems and for every request, it is spending 9 seconds to respond. In the section below there are the steps to create and simulate this “problematic” web service. WEB S ERVICE PROJECT 1. Start Oracle Enteprise Pack Eclipse 2. In the New Project window, select Web Service Project and click Next An Oracle Technical Article Page 3
  • 4. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out FIGURE 1 - NEW WEB SERVICE PROJECT PROJ 3. In the New Web Service Project window: a. Set the project name to Customer b. Set Target Runtime to Oracle Weblogic Server 11gR1 PatchSet 3 c. Click Finish 4. Right-click in the Customer project and create a new folder called schemas 5. Create a new XML Schema CustomerType.xsd FIGURE 2 - NEW XML SCHEMA This schema will have the data structure the Web Service will use. 6. Copy and paste the following schema definition into the CustomerType.xsd file <schema xmlns="http://www.w3.org/2001/XMLSchema" "http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/Customer" targetNamespace xmlns:tns="http://www.example.org/Customer" "http://www.example.org/Customer" elementFormDefault="qualified"> elementFormDefault <element name= ="customer" type="tns:CustomerType"></element> An Oracle Technical Article Page 4
  • 5. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out <complexType name name="CustomerType"> <sequence sequence> <element name="id" type="int"></element> <element name="firstname" type="string"></element> <element name="lastname" type="string"></element> <element name="address" type="tns:AddressType"></element element> </sequence sequence> </complexType>> <complexType name name="AddressType"> <sequence> <element name="street" type="string"></element> element <element name="country" type="string"></element> element <element name="city" type="string"></element> element </sequence> </complexType> </schema> 7. After pasting the content into CustomerType.xsd, right-click this file and select Generate > JAXB click Classes a. Set Package field to com.oracle.examples.entities and click Finish. FIGURE 3 - GENERATE JAVA CLASSE FROM XML SCHEMA USING JAXB CLASSES ING b. The console will output the following results: parsing a schema... compiling a schema... com/oracle/examples/entities/AddressType.java com/oracle/examples/entities/CustomerType.java com/oracle/examples/entities/ObjectFactory.java com/oracle/examples/entities/package-info.java com/oracle/examples/entities/package com/oracle/examples/entities/jaxb.properties 8. Select Java Resources under Project Explorer tab and click in Weblogic Web Service to create a new gic Web Service class. a. In the New Web Service window set: i. Package: com.oracle.examples.service ii. Name: Customer 9. Copy the following code into the Customer.java class created package com.oracle.examples.service; import javax.jws.WebMethod; import javax.jws.WebService; import com.oracle.examples.entities.AddressType; import com.oracle.examples.entities.CustomerType; import com.oracle.examples.entities.ObjectFactory; @WebService public class Customer { An Oracle Technical Article Page 5
  • 6. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example @WebMethod public CustomerType getCustomer(int id) { ObjectFactory factory = new ObjectFactory(); AddressType addressType = factory.createAddressType(); CustomerType customerType = factory.createCustomerType(); switch (id) { case 1: addressType.setCity("São Paulo"); addressType.setCountry("BRA"); addressType.setStreet("Marginal Pinheiros"); customerType.setId(1); customerType.setFirstname("João"); customerType.setLastname("Silva"); customerType.setAddress(addressType); break; case 2: addressType.setCity("San Francisco"); addressType.setCountry("USA"); addressType.setStreet("Some address"); customerType.setId(2); customerType.setFirstname("John"); customerType.setLastname("Lock"); customerType.setAddress(addressType); break; default: break; } // forcing slow down try { Thread.currentThread().sleep(9000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return customerType; } } This Web Service will return fixed values but of course you should change this and do a real Customer search in a database using JPA and/or Oracle TopLink. Also, to simulate the slowness on our Web Service there is a Thread.sleep() call that will cause our service to return only after 9 seconds. 10. Deploy this project to a running instance of Weblogic Server and hit the URLs below to see the WSDL and test using Weblogic Test Client. WSDL URL http://localhost:7001/Customer/CustomerService?WSDL TEST URL http://localhost:7001/wls_utc/?wsdlUrl=http://localhost:70 01/Customer/CustomerService?WSDL Note: You can deploy this project to same server you will be running Oracle Service Bus. 11. When you invoke the service method getCustomer notice that it really takes 9 seconds to execute. An Oracle Technical Article Page 6
  • 7. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out FIGURE 4 - PROBLEMATIC WEB SERV SERVICE RESPONSE In the next section we will import the service into Oracle Service Bus and then learn how service caching can reduce the impact of this performance problem. ervice ORACLE SERVICE BUS PROJECT In this section we will import the Web Service previously created and generate the Proxy and Business Services in a Service Bus project. For more details about Proxy and Business services please check the following link: http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/toc.htm IMPORT WEB S ERVICE RESOURCES 1. Open Oracle Service Bus Console: http://localhost:7001/sbconsole 2. Click in Project Explorer, start a Session and create a new project. Name it Customer for example. 3. Click in the Customer project and look for the Create Resource combo box. Select Resources from URL under Bulk. 4. Fill the form with the following information: a. URL/Path: http://localhost:7001/Customer/CustomerService?WSDL b. Resource Name: CustomerWSDL Name An Oracle Technical Article Page 7
  • 8. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out c. Resource Type: WSDL Type FIGURE 5 - IMPORT WSDL RESOURCE INTO ORACLE SERVICE BUS 5. Click Next and then Import. CREATE PROXY AND BUSINESS SERVICES 1. Click in the Customer project and look for Create Resource combo box. Select Business Service a. Service Name CustomerBS Name: b. Service Type: WSDL Web Service i. In the Select WSDL window, select CustomerWSDL. ii. Select CustomerPortBinding and Click Submit. c. Keep the protocol as HTTP and in the Endpoint URI set http://localhost:7001/Customer/CustomerService , which is the URL of the http://localhost:7001/Customer/CustomerService Web Service we created in the previous section. An Oracle Technical Article Page 8
  • 9. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example FIGURE 6 - BUSINESS SERVICE CREATION d. Click Last and then Save. 2. Back to the Customer project, Create Resource combo box and now select Proxy Service a. Service Name: CustomerPS b. Service Type: Create From Existing Service i. Select Business Service and point to CustomerBS. ii. We don’t need to modify any settings in the Proxy Service, so you can click Last and then Save. ACTIVATE AND TEST 1. Click Activate to save the changes done in this session and Submit. 2. Back to the Customer project, click in Launch Test Console under Actions column. 3. Now you can execute the Proxy Service and this will call our problematic Web Service. Since we hardcoded only two IDs, you can input only 1 or 2 to get some data in response. Other values will return an empty response document. An Oracle Technical Article Page 9
  • 10. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out FIGURE 7 - REQUEST WITH PERFORMANCE PROBLEMS PERFORM FIGURE 8 - WEB SERVICE RESPONSE AFTER 9 SECONDS Note that all service calls is really taking around 9 seconds to execute. Sometimes it can take a little bit longer with an additional 1 or 2 seconds, but never less than 9 seconds since this is the “response time” of our backend Web Service. In the next section we will demonstrate how Oracle Service Bus and Oracle Coherence are integrated and how you can escalate the solution using an out out-of-process caching strategy. process An Oracle Technical Article Page 10
  • 11. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example ORACLE COHERENCE INTEGRATION Oracle Service Bus always had some mechanics of caching in order to provide XQuery and XML beans caching also with object caching for Proxy and Business Services classes. But since release 11gR1, Oracle Service Bus offered an integrated solution for result caching with Oracle Coherence. The result caching in Oracle Service Bus is available for Business Services. When you enable result caching, the Business Service will not reach the back-end service and the response will come from the cache entry. This entry can expire and if the entry is expired, the next service call will indeed reach the back-end service and update the cache entry. FIGURE 9 - HOW RESULT CACHING WORKS For more details about how result caching works on Oracle Service Bus please check the following link from Fusion Middleware 11g documentation: http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15867/configuringandus ingservices.htm#OSBAG170 ACTIVATING CACHE FOR BUSINESS SERVICE To enable result caching for our Business Service follow these steps: 1. Click in Create at Change Center to create a new change session in Oracle Service Bus console. 2. Navigate to Customer project and click in the CustomerBS Business Service. 3. Click in Edit under Message Handling Configuration section. An Oracle Technical Article Page 11
  • 12. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out FIGURE 10 - ENABLE BUSINESS SERVICE RESULT CACHE SERV 4. Expand Advanced Settings and in Result Caching select Supported. 5. Set the Cache Token Expression: fn:data($body/ser:getCustomer/arg0) :getCustomer/arg0) FIGURE 11 - BUSINESS SERVICE CAC CACHING SETTINGS This will use the customer ID as our unique token for the cache entry. oken Also, set the Expiration Time for 10 minutes. 6. Click Last >> and Save to confirm the Business Service modifications. You can activate the change session. 7. Now click in Launch Test Console for CustomerPS proxy service and let’s test our configurations. The first time you execute the service, it takes 9 seconds to execute and it will populate our he cache entry. Click Back in the Test Console and try to execute again. It will show the results immediately, directly from a cache entry in the embedded Oracle Coherence Server running within Oracle Service Bus. The cache Expiration Time (Time-to-Live) was set to 10 minutes in ) 1 step 4, so during this period your calls will not hit the back back-end web service. An Oracle Technical Article Page 12
  • 13. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In this section we already provided one solution for our problematic service. But one can ask: What if I want to see what’s going on with my cache? Other will say: How many entries do I have in my cache server? And so on… Please check the next section for more details and a solution for development environments. COHERENCE CONSOLE INTEGRATION WITH ORACLE SERVICE BUS CACHE Oracle Coherence offers good APIs for JMX and Reports about cache servers and that’s definitely the way to go for monitoring production environments with huge loads. But for development environment and other critical monitoring situations, you can use the Coherence Console. Coherence Console is a self-contained command line utility that connects to specific Coherence Servers. It is a good tool to check which servers are participating in the cluster and let you browse the cache data. That’s the tool we will be using in the example to monitor our cache entries and Coherence servers. In order to integrate Coherence Console and Oracle Service Cache you need to specify a few things: 1. Create a file named consoleOSB.sh and paste the following text: #!/bin/sh # Middleware home MDW=/opt/oracle/osb11114 # Service Bus installation folder OSB=$MDW/Oracle_OSB # Domain home DM=/opt/oracle/domains/osb11gR1 # ---------------------------------------------------------------------------- if [ -f $JAVA_HOME/bin/java ]; then JAVAEXEC=$JAVA_HOME/bin/java else JAVAEXEC=java fi OPTS="-Xms64m -Xmx64m -Dtangosol.coherence.override=$DM/config/osb/coherence/osb-coherence- override.xml -Dtangosol.coherence.cacheconfig=$DM/config/osb/coherence/osb-coherence- cache-config.xml -Dtangosol.coherence.distributed.localstorage=false -Dtangosol.coherence.cluster=OSB-cluster -Dtangosol.coherence.localhost=localhost -DOSB.coherence.cluster=OSB-cluster" CP="$MDW/oracle_common/modules/oracle.coherence_3.6/coherence.jar" CP=$CP:"$MDW/modules/features/weblogic.server.modules.coherence.server_10.3.4.0 .jar" CP=$CP:"$OSB/lib/osb-coherence-client.jar" $JAVAEXEC -server -showversion $OPTS -cp $CP com.tangosol.net.CacheFactory $1 Note: You do not have to worry about the file location, you can place it anywhere. 2. Modify the script variables according to your installation settings. The variables are: a. Middleware home - MDW b. Oracle Service Bus installation directory - OSB c. Domain Home - DM An Oracle Technical Article Page 13
  • 14. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example 3. Give the file execution permission and execute the script in a terminal. You should see an output similar to the following: markito@anakin:~/Projects/PTS$ ./consoleOSB.sh … 2011-06-17 16:14:35.612/0.240 Oracle Coherence 3.6.0.4 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/opt/oracle/osb11114/oracle_common/modules/oracle.coherence_3.6/coherence.jar! /tangosol-coherence.xml" 2011-06-17 16:14:35.621/0.249 Oracle Coherence 3.6.0.4 <Info> (thread=main, member=n/a): Loaded operational overrides from "file:/opt/oracle/domains/osb11gR1/config/osb/coherence/osb-coherence-override.xml" 2011-06-17 16:14:35.629/0.257 Oracle Coherence 3.6.0.4 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified Oracle Coherence Version 3.6.0.4 Build 19111 Grid Edition: Development mode Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2011-06-17 16:14:36.127/0.755 Oracle Coherence GE 3.6.0.4 <Warning> (thread=main, member=n/a): Local address "127.0.0.1" is a loopback address; this cluster node will not connect to nodes located on different machines 2011-06-17 16:14:36.136/0.764 Oracle Coherence GE 3.6.0.4 <D4> (thread=main, member=n/a): TCMP bound to /127.0.0.1:7892 using SystemSocketProvider 2011-06-17 16:14:36.445/1.073 Oracle Coherence GE 3.6.0.4 <Info> (thread=Cluster, member=n/a): This Member(Id=4, Timestamp=2011-06-17 16:14:36.262, Address=127.0.0.1:7892, MachineId=26733, Location=site:localdomain,machine:localhost,process:13130, Role=CoherenceConsole, Edition=Grid Edition, Mode=Development, CpuCount=4, SocketCount=2) joined cluster "OSB- cluster" with senior Member(Id=1, Timestamp=2011-06-17 11:00:46.772, Address=127.0.0.1:7890, MachineId=26733, Location=site:localdomain,machine:localhost,process:5603, Role=OSB-node, Edition=Grid Edition, Mode=Development, CpuCount=4, SocketCount=2) 2011-06-17 16:14:36.454/1.082 Oracle Coherence GE 3.6.0.4 <D5> (thread=Cluster, member=n/a): Member 1 joined Service Cluster with senior member 1 2011-06-17 16:14:36.454/1.082 Oracle Coherence GE 3.6.0.4 <D5> (thread=Cluster, member=n/a): Member 1 joined Service Management with senior member 1 2011-06-17 16:14:36.454/1.082 Oracle Coherence GE 3.6.0.4 <D5> (thread=Cluster, member=n/a): Member 1 joined Service ORA-OSB-deployments with senior member 1 2011-06-17 16:14:36.457/1.085 Oracle Coherence GE 3.6.0.4 <Info> (thread=main, member=n/a): Started cluster Name=OSB-cluster WellKnownAddressList(Size=2, WKA{Address=127.0.0.1, Port=9999} WKA{Address=127.0.0.1, Port=7890} ) MasterMemberSet ( ThisMember=Member(Id=4, Timestamp=2011-06-17 16:14:36.262, Address=127.0.0.1:7892, MachineId=26733, Location=site:localdomain,machine:localhost,process:13130, Role=CoherenceConsole) OldestMember=Member(Id=1, Timestamp=2011-06-17 11:00:46.772, Address=127.0.0.1:7890, MachineId=26733, Location=site:localdomain,machine:localhost,process:5603, Role=OSB- node) ActualMemberSet=MemberSet(Size=2, BitSetCount=2 Member(Id=1, Timestamp=2011-06-17 11:00:46.772, Address=127.0.0.1:7890, MachineId=26733, Location=site:localdomain,machine:localhost,process:5603, Role=OSB- node) Member(Id=4, Timestamp=2011-06-17 16:14:36.262, Address=127.0.0.1:7892, MachineId=26733, Location=site:localdomain,machine:localhost,process:13130, Role=CoherenceConsole) ) RecycleMillis=1200000 RecycleSet=MemberSet(Size=0, BitSetCount=0 ) ) TcpRing{Connections=[1]} IpMonitor{AddressListSize=0} 2011-06-17 16:14:36.500/1.128 Oracle Coherence GE 3.6.0.4 <D5> (thread=Invocation:Management, member=4): Service Management joined the cluster with senior service member 1 Map (?): An Oracle Technical Article Page 14
  • 15. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example 4. Now you are already connected to the same Oracle Coherence cluster with Oracle Service Bus. There are various commands available for Coherence Console, please check the documentation for a complete list. Let’s check our cache entries: a. Type cache /osb/service/ResultCache and hit enter: Map (?): cache /osb/service/ResultCache 2011-06-17 16:27:25.807/770.435 Oracle Coherence GE 3.6.0.4 <Info> (thread=main, member=4): Loaded cache configuration from "file:/opt/oracle/domains/osb11gR1/config/osb/coherence/osb-coherence-cache- config.xml" 2011-06-17 16:27:26.352/770.980 Oracle Coherence GE 3.6.0.4 <D5> (thread=DistributedCache:ORA-OSB-deployments, member=4): Service ORA-OSB- deployments joined the cluster with senior service member 1 <distributed-scheme> <scheme-name>expiring-distributed</scheme-name> <service-name>ORA-OSB-deployments</service-name> <backing-map-scheme> <local-scheme> <scheme-ref>expiring-backing-map</scheme-ref> </local-scheme> </backing-map-scheme> <autostart>true</autostart> </distributed-scheme> b. Type list or size commands and you should see no results if you are following our example. That’s because our entries expired (10 minutes, remember?) and we now must execute the Proxy Service CustomerPS again to populate our cache server entries. If your cache is still valid (not expired) you will get different results and of course your entry will be already there. 5. Get back to the Service Bus console, Launch the Test Client again and execute CustomerPS. 6. Go to the Coherence Console and type list or size commands. You should see the following output (before and after testing): Map (/osb/service/ResultCache): list Map (/osb/service/ResultCache): size 0 Map (/osb/service/ResultCache): size 1 Map (/osb/service/ResultCache): list PipelineResultCacheKey[BusinessService Customer/CustomerBS,getCustomer,1) = owner=BusinessService Customer/CustomerBS,value=[B@58c16b18 7. Go back to the Service Bus Test client and try to execute with a different Customer ID that you used in the previous execution. You should see 2 entries and after 10 minutes, they will expire. CREATING A NEW EXTERNAL COHERENCE SERVER FROM WEBLOGIC CONSOLE Now that we already have our service cache enabled, we will have a better throughput performance and can attend much more users in our system. That is true but remembers we are still using an in-process strategy and this means that we are using the same JVM memory for cache entries, Weblogic services like JDBC or JMS, and Oracle Service Bus objects, like transformations, Proxy Services and Business Services. If we increase our cache usage to a high volume, we can go out of memory easily and compromise all other services in the Enterprise Service Bus, even the ones that are not using cache features, in a worst case scenario. An Oracle Technical Article Page 15
  • 16. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out To solve this situation you can use an external Coherence Server. That will be a dedicated JVM with its own Coherence Server. This solution can increase the scalability of our overall architecture and a more complex Coherence Cluster infrastructure can take in place. It is out of the scope of this article discuss the configuration frastructure of Coherence Clusters, but it will give an idea of what can be achieved and then adjusted for your situation. These are the steps to add a new Coherence server using Weblogic Console: 1. Log into Weblogic console: http://localhost:7001/console 2. If you are running a domain without a Machine associated in Weblogic, you have to add a machine and associate the Coherence Server with this Machine. Expand Environment in the left menu and select Machines Machines. 3. Fill up the New Machine form with the following information: a. Name: anakin [replace with your machine name] b. Machine OS: Unix [replace with your OS] c. Click Next FIGURE 12 - ADDING A NEW MACHINE 4. In the Node Manager Properties form use the following information: e a. Type: Plain [change it to SSL or SSH for production environments] change b. Listen Address: localhost c. Listen Port: 5556 d. Click Finish FIGURE 13 - NODE MANAGER PROPERT PROPERTIES An Oracle Technical Article Page 16
  • 17. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out Later we will setup the node manager scripts to complete this step. 5. Expand Environment select Coherence Servers in the left menu and click in New Environment, 6. Fill up this form with the following information: a. Name: server1 b. Machine: anakin [or replace with the machine name used in step 3] or 3 c. Unicast Listen Address: localhost d. Unicast Listen Port: 9999 e. Click Finish Finish. FIGURE 14 – CREATING A NEW COHERENCE SERVER COHER 7. In the Coherence servers screen, click in server1. We need to adjust the class path of this server to ervers integrate with Oracle Service Bus. 8. In the Settings for server1 screen, click in Server Start tab and fill the following fields: a. Java Home: /opt/oracle/jrockit-jdk1.6.0_20-R28.1.0-4.0.1 4.0.1 [set to your java home location] set location b. BEA Home: /opt/oracle/osb11114/ [set to your Oracle Service Bus installation directory] c. Class Path: /opt/oracle/osb11114/modules/features/weblogic.server.modules.coherence.server_10 .3.4.0.jar:/opt/oracle/osb11114/coherence_3.6/lib/coherence.jar:/opt/oracle/osb11 114/Oracle_OSB/lib/osb-coherence-client.jar 114/Oracle_OSB/lib/osb [replace /opt/oracle/osb11114/ with your Oracle Service Bus installation directory] rvice directory d. Arguments: - Dtangosol.coherence.override=/opt/oracle/domains/osb11gR1/ Dtangosol.coherence.override= domains/osb11gR1/config/osb/coherence/os b-coherence coherence-override.xml - Dtangosol.coherence.cacheconfig=/opt/oracle/domains/osb11gR1/ Dtangosol.coherence.cacheconfig= domains/osb11gR1/config/osb/coherence /osb-coherence coherence-cache-config.xml -Dtangosol.coherence.distributed.localstorage=true Dtangosol.coherence.distributed.localstorage=true -Dtangosol.coherence.cluster=OSB Dtangosol.coherence.cluster=OSB-cluster -Dtangosol.coherence.localhost=localhost Dtangosol.coherence.localhost=localhost -DOSB.coherence.cluster=OSB DOSB.coherence.cluster=OSB-cluster [replace /opt/domains/osb11gR1/ with your Oracle Service Bus domain directory] An Oracle Technical Article Page 17
  • 18. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out Note: In order to use this Coherence server as storage node the tangosol.coherence.distributed.localstorage property needs to be true. e. Click Save. FIGURE 15 - COHERENCE SERVER SETTINGS SET 9. Now we need to add our new server to the WKA (Well Known Address) list of Coherence Servers in the Oracle Service Bus configuration. a. In the command terminal, browse to /opt/oracle/domains/osb11gR1/config/osb/coherence b. Edit the osb--coherence-override.xml file and update according the following snippet: <!DOCTYPE coherence SYSTEM "coherence.dtd"> <coherence> <cluster--config> <!-- By specifying a well well-known-address we disable the mutlicast listener. address This ensures that the Coherence cluster for OSB will be isolated to this machine only. --> <unicast-listener> <well-known-addresses> <socket-address id="1"> <address system-property="OSB.coherence.wka1">127.0.0.1</address> property="OSB.coherence.wka1">127.0.0.1</address> <port system-property="OSB.coherence.wka1.port">7890</port> property="OSB.coherence.wka1.port">7890</port> </socket-address> <socket-address id="2"> <address system-property="OSB.coherence.wka2">127.0.0.1</address> property="OSB.coherence.wka2">127.0.0.1</address> <port system-property="OSB.coherence.wka2.port">9999</port> property="OSB.coherence.wka2.port">9999</port> </socket-address> </well-known-addresses> <address system system-property="OSB.coherence.localhost">127.0.0.1</address> oherence.localhost">127.0.0.1</address> <port system-property="OSB.coherence.localport">7890</port> system property="OSB.coherence.localport">7890</port> </unicast-listener> <multicast-listener> <time-to-live system-property="OSB.coherence.tt property="OSB.coherence.ttl">0</time-to-live> </multicast-listener> </cluster-config> </cluster </coherence> Here we are adding a new socket address to the Oracle Coherence cluster. For security and performance reasons, Oracle Coherence server that is bundled with Oracle Service An Oracle Technical Article Page 18
  • 19. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example Bus uses WKA and Unicast, so for every new node you add to the cluster this file needs to be updated or make sure that at least one of the nodes specified here is running when trying to start other nodes unlisted. In this case, we are specifying a new server listening in the localhost address (127.0.0.1) and port 9999. c. Save and close osb-coherence-override.xml. Note: You can also perform the same configuration shown in this step (step 9) through adding two more properties in the Coherence server configuration in Weblogic Console: -DOSB.coherence.wka2=localhost -DOSB.coherence.wka2.port=9999 10. Now it is time to test all we have done so far, please do the following: a. Shutdown Oracle Service Bus domain. b. In a command terminal, browse to /opt/oracle/osb11114/wlserver_10.3/server/bin where /opt/oracle/osb11114/ is your Oracle Service Bus installation directory. c. Execute the script to start the node manager: ./startNodeManager.sh d. Start your Oracle Service Bus domain. e. Go to the Weblogic Server console: http://localhost:7001/console f. Expand Environment in the menu on the left and click in Coherence Servers. g. Click in Control tab, mark server1 and click in Start. h. Note that the State column value changed to Starting and after a few seconds to Running. Congratulations, you have a new Coherence Server up and running integrated with Oracle Service Bus and can manage your server through Weblogic Console with the help of a Node Manager. In the next sections we will test this integration and play with our cache server. OUT-OF -PROCESS CACHING WITH EXTERNAL COHERENCE SERVER Now it is time to test our out-of-process strategy caching and execute our problematic web service again. Remember that we still have both servers able to store cached data, the internal server bundled with Oracle Service Bus and the external server1 because they have tangosol.coherence.distributed.localstorage property set to true. To test your out-of-process cache you can do the following: 1. Open a command terminal and browse to the consoleOSB.sh script that we created before. Execute. You should see the following output: ……… … WellKnownAddressList(Size=2, WKA{Address=127.0.0.1, Port=7890} WKA{Address=127.0.0.1, Port=9999} An Oracle Technical Article Page 19
  • 20. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example ) MasterMemberSet ( ThisMember=Member(Id=3, Timestamp=2011-06-20 15:03:22.947, Address=127.0.0.1:7894, MachineId=8417, Location=site:localdomain,machine:localhost,process:11912, Role=CoherenceConsole) OldestMember=Member(Id=1, Timestamp=2011-06-20 14:34:49.401, Address=127.0.0.1:7890, MachineId=8417, Location=site:localdomain,machine:localhost,process:10716, Role=OSB- node) ActualMemberSet=MemberSet(Size=3, BitSetCount=2 Member(Id=1, Timestamp=2011-06-20 14:34:49.401, Address=127.0.0.1:7890, MachineId=8417, Location=site:localdomain,machine:localhost,process:10716, Role=OSB- node) Member(Id=2, Timestamp=2011-06-20 14:47:55.749, Address=127.0.0.1:7892, MachineId=8417, Location=site:localdomain,machine:localhost,process:11562,member:server1, Role=WeblogicWeblogicCacheServer) Member(Id=3, Timestamp=2011-06-20 15:03:22.947, Address=127.0.0.1:7894, MachineId=8417, Location=site:localdomain,machine:localhost,process:11912, Role=CoherenceConsole) ) RecycleMillis=1200000 RecycleSet=MemberSet(Size=0, BitSetCount=0 ) ) TcpRing{Connections=[2]} IpMonitor{AddressListSize=0} Note that you have now two address in the Well Know Address List and three members in the Coherence cluster: OSB-node (internal), server1 (external) and CoherenceConsole (which is the console we are using). 2. In the Oracle Coherence Console, enter in Oracle Service Bus ResultCache: Map (?): cache /osb/service/ResultCache 3. In the web browser, log in Oracle Service Bus console: http://localhost:7001/sbconsole 4. Click in Project Explorer, browse to Customer project and Launch Test Console for CustomerPS proxy service. 5. Execute the service and you should experience the 9 seconds execution time for the first call. Click Back, execute again and your result should be immediate, just like we did previously. 6. Type size or list in the Coherence console and you will see one entry. 7. To validate our external cache server and check if it is working, shutdown Oracle Service Bus domain. 8. Type size or list again in the Coherence console and you should still see one entry. That’s it! The external Coherence Server is holding our data for 10 minutes. 9. Start Oracle Service Bus domain, log in sbconsole and re-execute CustomerPS proxy service. You will see an immediate response because the data is still coming from the cache and not the back-end service. Note: Remember to use the same customer ID attempted in step 5, otherwise your call will hit the back-end service. SET INTERNAL COHERENCE SERVER STORAGE TO FALSE As we can see in the previous section the external Coherence server (server1) is already taking care of cached data storage. But we are still doing cache in both Coherence servers, internal and external, and for a production environment it may be a good idea to disable the storage of internal Coherence server and free some An Oracle Technical Article Page 20
  • 21. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example JVM memory that can be used for other services like JDBC, JMS or service processing. With this change all cached data will be stored only in the external Coherence server (server1). To execute these settings follow the steps below: 1. Make sure you have the external Oracle Coherence (server1) already running with storage enabled. Otherwise you will see many exceptions in Oracle Service Bus logs complaining that Service Result Caching functionality is disabled. This happens because there will be no cache servers with storage enabled in the Coherence Cluster and because of that caching will not be possible. 2. Open a command terminal and browse to the Oracle Service Bus domain directory. 3. Open /opt/oracle/domains/osb11gR1/bin/startDomainEnv.sh in a text editor and look for the following line: JAVA_OPTIONS="${JAVA_OPTIONS} ${JAVA_PROPERTIES} -Dwlw.iterativeDev=${iterativeDevFlag} -Dwlw.testConsole=${testConsoleFlag} -Dwlw.logErrorsToConsole=${logErrorsToConsoleFlag} " 4. Modify this line to look like the one below: JAVA_OPTIONS="${JAVA_OPTIONS} ${JAVA_PROPERTIES} -Dwlw.iterativeDev=${iterativeDevFlag} -Dwlw.testConsole=${testConsoleFlag} -Dwlw.logErrorsToConsole=${logErrorsToConsoleFlag} -Dtangosol.coherence.distributed.localstorage=false " 5. Save and close the startDomainEnv.sh file. 6. Restart your Oracle Service Bus domain to apply the changes. 7. Once your server is starting, look for the line we modified in step 3 in the starting information that Weblogic outputs. /opt/oracle/jrockit-jdk1.6.0_20-R28.1.0-4.0.1/bin/java -jrockit -Xdebug -Xnoagent - Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n -Djava.compiler=NONE - Xms648m -Xmx768m -Dweblogic.Name=AdminServer - Djava.security.policy=/opt/oracle/osb11114/wlserver_10.3/server/lib/weblogic.policy - Xverify:none -da:org.apache.xmlbeans... -ea -da:com.bea... -da:javelin... - da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole... - Dplatform.home=/opt/oracle/osb11114/wlserver_10.3 - Dwls.home=/opt/oracle/osb11114/wlserver_10.3/server - Dweblogic.home=/opt/oracle/osb11114/wlserver_10.3/server - Dcommon.components.home=/opt/oracle/osb11114/oracle_common -Djrf.version=11.1.1 - Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger - Ddomain.home=/opt/oracle/domains/osb11gR1 - Djrockit.optfile=/opt/oracle/osb11114/oracle_common/modules/oracle.jrf_11.1.1/jrocket_op tfile.txt - Doracle.server.config.dir=/opt/oracle/domains/osb11gR1/config/fmwconfig/servers/AdminSer ver -Doracle.domain.config.dir=/opt/oracle/domains/osb11gR1/config/fmwconfig - Digf.arisidbeans.carmlloc=/opt/oracle/domains/osb11gR1/config/fmwconfig/carml - Digf.arisidstack.home=/opt/oracle/domains/osb11gR1/config/fmwconfig/arisidprovider - Doracle.security.jps.config=/opt/oracle/domains/osb11gR1/config/fmwconfig/jps-config.xml -Doracle.deployed.app.dir=/opt/oracle/domains/osb11gR1/servers/AdminServer/tmp/_WL_user -Doracle.deployed.app.ext=/- - Dweblogic.alternateTypesDirectory=/opt/oracle/osb11114/oracle_common/modules/oracle.osso iap_11.1.1,/opt/oracle/osb11114/oracle_common/modules/oracle.oamprovider_11.1.1 - Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dweblogic.jdbc.remoteEnabled=false -Dem.oracle.home=/opt/oracle/osb11114/oracle_common -Djava.awt.headless=true - Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= - Dwlw.logErrorsToConsole= -Dtangosol.coherence.distributed.localstorage=false - Dweblogic.ext.dirs=/opt/oracle/osb11114/patch_wls1034/profiles/default/sysext_manifest_c lasspath:/opt/oracle/osb11114/patch_ocp360/profiles/default/sysext_manifest_classpath weblogic.Server 8. Now execute the CustomerPS proxy service. An Oracle Technical Article Page 21
  • 22. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example In Process Out 9. Back to the command terminal, execute the consoleOSB.sh (Coherence Console) and type size nd or list commands. You should still see one entry in the cache but now it is stored only in the external Coherence server (server1) and the Oracle Service Bus internal Coherence server is now ( ) acting as client node only. CONCLUSION In this article was presented two different cache strategies and the benefits of using out-of-process out caching with Oracle Coherence and Oracle Service Bus. There was an example of a Web Service with performance problems exposed in Oracle Service Bus and through the use of result caching the response time e improvement is clear. Also the Oracle Coherence Console integration with Oracle Service Bus is an alternative for development and troubleshooting of service caching solutions capable to show the running servers and cached caching data information. Out-of-process caching can drastically reduce the JVM memory footprint of an Oracle Service Bus process domain and increase the scalability and fail fail-over of the architecture and it is a recommended approach for projects that needs to scale safely. REFERENCES Link Description http://download.oracle.com/docs/cd/E21764_01/doc.1111/e1586 Documentation about Result Cache in Oracle Service 7/configuringandusingservices.htm#OSBAG170 Bus http://coherence.oracle.com/display/COH/Oracle+Coherence+Kn /coherence.oracle.com/display/COH/Oracle+Coherence+Kn Coherence Knowledge Base with documentation, owledge+Base+Home Screencasts and examples http://mazanatti.info/index.php?/archives/65 ttp://mazanatti.info/index.php?/archives/65-Connecting-a- Script that connects to Oracle Coherence console and console-to-an-OSB-Coherence-cluster.html cluster.html Oracle Service Bus http://www.oracle.com/technetwork/middleware/service- http://www.oracle.com/technetwork/middleware/service Oracle Service Bus documentation index bus/documentation/index.html ABOUT THE AUTHOR William Markito Oliveira is a Senior Technologist at Oracle Platform Technology Solutions team in Brazil where he focuses in Middleware, SOA and Java Middleware technologies. Work also as contributor to the official Java EE 6 Tutorial providing write ups and code examples about CDI, EJB 3.1 and JAX-RS. Has write-ups more than 8 years of experience in Software Development, Consulting and Architecture, previously working as a Solution Architect in several companies. An Oracle Technical Article Page 22
  • 23. Oracle Service Bus and Oracle Coherence: An In-Process and Out-of-Process Cache Example An Oracle Technical Article Page 23