注意:

在 Oracle Visual Builder Studio 中部署 Oracle SOA Suite

簡介

Oracle Visual Builder Studio is the official Oracle tool for automating DevOps processes with different technologies like:

本教學課程示範如何在 Oracle SOA Suite 中導入下列功能的範例。

重要注意事項:目前只能透過 Oracle Visual Builder Studio 使用 Oracle SOA Suite 導入 CI/CD。這是因為虛擬機器中已經預先安裝 Visual Builder Studio 的 Plug-in,無法處理和編譯 (BUILD) 必要的套裝程式。因此,尚無法以 Jenkins 等其他市場工具導入 CI/CD。

目標

在 SOA Suite 中導入專案,透過 DevOps 處理作業與 Oracle Visual Builder Studio 自動部署。

必要條件

下列各項相關知識:

作業 1:建立您的 Oracle Streaming 執行處理

Oracle Cloud Streaming 是一款應用系統,旨在作為訊息佇列,就像開源 Kafka 工具一樣。Oracle Streaming 是一個託管的解決方案,意味著您建立了一個可供使用的執行處理,無須擔心基礎架構的治理問題。只需依據使用量付費。此工具也可讓您使用 Kafka 的 REST API,以「雲端即服務」的優點,與現有的 Kafka 專案相容。

在本教學課程中,我們將執行 SOA 服務實作來產生與其他服務,以使用訊息佇列中的資料。因此,第一站將佈建 Oracle Streaming 環境。

作業 2:在 JDeveloper 中建立您的 SOA Suite 專案

我們將會建立 Oracle Cloud Streaming 的執行處理,以取代 Kafka。建立具有下列目標的專案:

此教學課程包含完整的專案。您可以變更編譯、封裝以及部署到 SOA Suite 執行處理的設定值。

注意:本教學課程並不包括導入 REST 服務的詳細步驟。如需詳細資訊,請參閱 How to Implement and Consume REST Services with Oracle SOA Suite

  1. 請使用以下連結下載 SOAKafkaProducerApp 專案:SOAKafkaProducerApp.zip

    • 尋找 /SOAKafkaProducerApp/SOAKafkaProducerApp/SOAKafkaProducerApp.jws 應用程式檔案。

    • 您可以檢視 JDeveloperSOAKafkaProducerPrjSOAKafkaConsumerPrj 中的專案

  2. 按一下應用程式樹狀結構並尋找 SOAKakfaConsumerPrj ,然後按兩下 KafkaConsumer,如下圖所示。

    jdev-soa-1.png

    • 這是 Kafka 佇列使用量的 SOA 專案願景。這是 SOA 複合項目類型的一般實作。這是 REST 服務 ( 公開的服務路徑中配置的元件),必須部署在 SOA 伺服器上。連結至服務的元件是服務本身的實作,並安排在元件泳道中,如上一個影像所示。按兩下 KafkaConsumer 元件,即會引導您導入服務,如下所示:

      jdev-bpel-1.png

    • 第一個導入階段從名為「接收」的元件開始,負責接收典型的 REST 呼叫初始工作參數。在本教學課程中,我們將不會傳送參數,但會在此說明需要此資源的服務。

      jdeve - receive-1.png

      jdev 接收 -detail.png

      jdev-bpel-code.png

    • 「Java 內嵌」元件負責呼叫 Java 常式,在此情況下,會稍後呼叫名為 KafaExample 的類別。

      jdev 嵌入式 -code-1.png

    • 在此 Java 嵌入中呼叫的 Java 程式碼,負責 Kafka 或 Oracle Stream 佇列生產和使用常式 (請記住,Oracle Streaming 的 API 與 Kakfa 相容)。

      java
      		package soakafka;
      
      		import org.apache.kafka.clients.consumer.ConsumerRecord;
      		import org.apache.kafka.clients.consumer.ConsumerRecords;
      		import org.apache.kafka.clients.consumer.KafkaConsumer;
      		import org.apache.kafka.clients.producer.KafkaProducer;
      		import org.apache.kafka.clients.producer.Producer;
      		import org.apache.kafka.clients.producer.ProducerRecord;
      		import org.apache.kafka.common.serialization.StringSerializer;
      		import org.apache.kafka.common.serialization.StringDeserializer;
      
      		import java.util.Arrays;
      		import java.util.Date;
      		import java.util.Properties;
      
      		import java.util.concurrent.ExecutionException;
      
      		import org.apache.kafka.clients.producer.Callback;
      		import org.apache.kafka.common.errors.WakeupException;
      
      		public class KafkaExample {
      		    private final String topic;
      		    private final Properties props;
      
      		    public KafkaExample(String brokers, String username, String password) {
      		        this.topic = "kafka_like";
      
      		        String jaasTemplate = "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"%s\" password=\"%s\";";
      		        String jaasCfg = String.format(jaasTemplate, username, password);
      
      		        String serializer = StringSerializer.class.getName();
      		        String deserializer = StringDeserializer.class.getName();
      		        //Propriedades
      		        props = new Properties();
      		        props.put("bootstrap.servers", brokers);
      		        props.put("group.id", "kafka-hoshikawa");
      		        props.put("enable.auto.commit", "false");
      		        props.put("max.poll.records", "10");
      		        props.put("auto.offset.reset", "earliest");
      		        props.put("key.deserializer", deserializer);
      		        props.put("value.deserializer", deserializer);
      		        props.put("security.protocol", "SASL_SSL");
      		        props.put("sasl.mechanism", "PLAIN");
      		        props.put("sasl.jaas.config", jaasCfg);
      		        //props.put("ssl.client.auth", "requested");
      		    }
      
      		    public String consume() {
      		        String ret = "";
      		        KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
      		        consumer.subscribe(Arrays.asList(topic));
      
      		        try {
      		          while (true) {
      		            ConsumerRecords<String, String> records = consumer.poll(100);
      		            for (ConsumerRecord<String, String> record : records)
      		            {
      		              System.out.println(record.offset() + ": " + record.value());
      		              ret = ret + record.value();
      		            }
      		              if (ret != "")
      		                break;
      		          }
      		        } catch (Exception e) {
      		          // ignore for shutdown
      		        } finally {
      		          consumer.commitAsync();
      		          consumer.close();
      		        }
      		        return ret;
      		    };
      
      		    public void produce(String message) {
      		        Producer<String, String> producer = new KafkaProducer<String, String>(props);
      		        ProducerRecord record = new ProducerRecord<String, String>(topic, "msg", message);
      
      		        Callback callback = (data, ex) -> {
      		            if (ex != null) {
      		                ex.printStackTrace();
      		                return;
      		            }
      		            System.out.println(
      		                "Mensagem enviada com sucesso para: " + data.topic() + " | partition " + data.partition() + "| offset " + data.offset() + "| tempo " + data
      		                    .timestamp());
      		        };
      		        try {
      		            producer.send(record, callback).get();
      		        } catch (ExecutionException | InterruptedException e) {
      		        }
      		        finally {
      		            producer.close();
      		        }
      		    }
      
      		    public static void main(String[] args) {
      		                /*
      				String brokers = System.getenv("CLOUDKARAFKA_BROKERS");
      				String username = System.getenv("CLOUDKARAFKA_USERNAME");
      				String password = System.getenv("CLOUDKARAFKA_PASSWORD");
      		                */
      		                String brokers = "cell-1.streaming.us-ashburn-1.oci.oraclecloud.com:9092";
      		                String username = "hoshikawaoraclecloud/oracleidentitycloudservice/hoshikawa2@hotmail.com/ocid1.streampool.oc1.iad.amaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxkgztajzakb5a";
      		                String password = "Wxxxxxxxxxxxxxxxxxxxxxxk";
      				KafkaExample c = new KafkaExample(brokers, username, password);
      		        c.consume();
      		    }
      		}
      
      		    public static void main(String[] args) {
      		                /*
      				String brokers = System.getenv("CLOUDKARAFKA_BROKERS");
      				String username = System.getenv("CLOUDKARAFKA_USERNAME");
      				String password = System.getenv("CLOUDKARAFKA_PASSWORD");
      		                */
      		                String brokers = "cell-1.streaming.us-ashburn-1.oci.oraclecloud.com:9092";
      		                String username = "hoshikawaoraclecloud/oracleidentitycloudservice/zzzzzzzzz2@zzzzzzil.com/ocid1.streampool.oc1.iad.amaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxkgztajzakb5a";
      		                String password = "Wxxxxxxxxxxxxxxxxxxxxxxk";
      				KafkaExample c = new KafkaExample(brokers, username, password);
      		        c.consume();
      		    }
      		}
      
      
      

      jdev-assign-1.png

      jdev-assign-details.png

      jdev-reply-1.png

      jdev-reply-details.png

  3. 在您的程式碼中以 Maven 包括 Java 套裝程式。

    • 在這個專案中,我們導入 Java 程式碼以呼叫 Kafka 或 Oracle Cloud Streaming API。因為它是 Java 程式碼,所以通常需要套件內含項目才能使用架構。在這些情況下,Maven 是最常使用的工具,因此您必須將其納入專案中。使用滑鼠右鍵,開啟專案上的選項,然後選取從圖庫,如下圖所示。

      soa-create-pom-file.png

    • 選取 專案的 Maven POM 選項。

      soa-maven-select.png

    現在,您可以使用必要的架構來配置套裝軟體。

  4. 使用 Maven 進行組建。

    • 按一下 [Application Windows] (應用程式視窗) 選項,然後按一下 [Directory View] (目錄檢視) 以存取 /SOA/SCA-INF/pom.xml 檔案。

      View-maven-pom-xml-file.png

      檔案 -pom-xml-file2.png

    • 按兩下 pom.xml 檔案以在 JDeveloper 編輯器中開啟該檔案,然後選取來源頁籤以檢視程式碼。

    • 如此一來,您便能夠以視覺化方式呈現 pom.xml 檔案的程式碼。

      pom-xml-original.png

    • 以下是 DevOps 程序的重大變更。您必須包含這些自動化明細行。

      注意:此教學課程中的專案已設定為支援 DevOps 自動化,但對於新專案,請遵循此程序來自動化 DevOps 程序。在 標籤和 標籤之間,您可以包含此程式碼,這將會負責組合您的套裝軟體,以用於日後部署 **Ant**。

      如果是 DevOps 自動化,您必須包含下列 3 行。

      <directory>target</directory>

      <outputDirectory>classes</outputDirectory>

      <sourceDirectory>src</sourceDirectory>

      devops-pom-xml.png

      因此,您的完整程式碼可能如下:

      xml
          pom.xml
      
          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
      
            <groupId>soakafka</groupId>
            <artifactId>kafka</artifactId>
            <version>1.0-SNAPSHOT</version>
      
            <dependencies>
              <dependency>
                <groupId>org.apache.kafka</groupId>
                <artifactId>kafka-clients</artifactId>
                <version>1.0.0</version>
              </dependency>
            </dependencies>
      
            <build>
      
              <!-- For DevOps automation, you need to include the 3 lines below - Cristiano Hoshikawa - 2020-11-28 -->        
              <directory>target</directory>
              <outputDirectory>classes</outputDirectory>
              <sourceDirectory>src</sourceDirectory>
      
              <plugins>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>3.1</version>
                  <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                  </configuration>
                </plugin>
                <plugin>
                  <artifactId>maven-assembly-plugin</artifactId>
                  <configuration>
                    <archive>
                      <manifest>
                        <mainClass>KafkaExample</mainClass>
                      </manifest>
                    </archive>
                    <descriptorRefs>
                      <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                  </configuration>
                  <executions>
                    <execution>
                      <id>make-assembly</id> <!-- this is used for inheritance merges -->
                      <phase>package</phase> <!-- bind to the packaging phase -->
                      <goals>
                        <goal>single</goal>
                      </goals>
                    </execution>
                  </executions>
                </plugin>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-jar-plugin</artifactId>
                  <version>3.0.2</version>
                  <configuration>
                    <archive>
                      <manifest>
                        <mainClass>KafkaExample</mainClass>
                        <addClasspath>true</addClasspath>
                      </manifest>
                    </archive>
                  </configuration>
                </plugin>
              </plugins>
            </build>  
          </project>
      
      
  5. 使用 Ant 建置與部署。

    • Ant 是市場知名的工具,由 Jakarta 專案開發,負責自動化 Java 等專案的編譯、套裝程式組建和應用程式部署。在 DevOps 程序中, Ant 將是建立 SOA Suite 套裝軟體的基礎,以及在遠端 Weblogic SOA Suite 伺服器上部署此套裝軟體。

    • 若要建立您的 build.xml 檔案,請使用滑鼠右鍵開啟專案上的選項,然後選取從圖庫,如下列影像所示。

      soa-create-pom-file.png

    • 在左側功能表中選取 Ant 選項,然後按一下從專案建立檔案

      soa-create-ant.png

    • build.xml 檔案是相當常見的配置檔案,可供 Ant 使用。

      xml
          build.xml
      
          <?xml version="1.0" encoding="UTF-8" ?>
          <!--Ant buildfile generated by Oracle JDeveloper-->
          <!--Generated Oct 12, 2020 11:35:33 PM-->
          <project xmlns="antlib:org.apache.tools.ant" name="SOAKafkaProducerPrj" default="all" basedir=".">
            <property environment="env" />
            <property file="build.properties"/>
            <path id="library.SOA.Designtime">
              <pathelement location="${install.dir}/soa/plugins/jdeveloper/extensions/oracle.sca.modeler.jar"/>
            </path>
            <path id="library.SOA.Runtime">
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar"/>
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.fabric_11.1.1/tracking-api.jar"/>
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.fabric_11.1.1/tracking-core.jar"/>
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.fabric_11.1.1/edn.jar"/>
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar"/>
              <pathelement location="${oracle.commons}/modules/com.oracle.webservices.fabric-common-api.jar"/>
            </path>
            <path id="library.BPEL.Runtime">
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.bpel_11.1.1/orabpel.jar"/>
            </path>
            <path id="library.Mediator.Runtime">
              <pathelement location="${install.dir}/soa/soa/modules/oracle.soa.mediator_11.1.1/mediator_client.jar"/>
            </path>
            <path id="library.MDS.Runtime">
              <pathelement location="${oracle.commons}/modules/oracle.mds/mdsrt.jar"/>
            </path>
            <path id="library.BC4J.Service.Runtime">
              <pathelement location="${oracle.commons}/modules/oracle.adf.model/adfbcsvc.jar"/>
              <pathelement location="${oracle.commons}/modules/oracle.adf.model/adfbcsvc-share.jar"/>
              <pathelement location="${oracle.commons}/modules/commonj.sdo.backward.jar"/>
              <pathelement location="${oracle.commons}/modules/commonj.sdo.jar"/>
              <pathelement location="${oracle.commons}/modules/oracle.toplink/eclipselink.jar"/>
              <pathelement location="${oracle.commons}/modules/com.oracle.webservices.fmw.wsclient-impl.jar"/>
              <pathelement location="${oracle.commons}/modules/com.oracle.webservices.fmw.jrf-ws-api.jar"/>
              <pathelement location="${oracle.commons}/modules/com.oracle.webservices.fmw.web-common-schemas-impl.jar"/>
            </path>
            <path id="classpath">
              <path refid="library.SOA.Designtime"/>
              <path refid="library.SOA.Runtime"/>
              <path refid="library.BPEL.Runtime"/>
              <path refid="library.Mediator.Runtime"/>
              <path refid="library.MDS.Runtime"/>
              <path refid="library.BC4J.Service.Runtime"/>
            </path>
            <target name="init">
              <tstamp/>
              <mkdir dir="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA/SCA-INF/classes"/>
            </target>
            <target name="all" description="Build the project" depends="deploy,copy"/>
            <target name="clean" description="Clean the project">
              <delete includeemptydirs="true" quiet="true">
                <fileset dir="${output.dir}" includes="**/*"/>
              </delete>
            </target>
            <target name="compile" depends="init">
                <javac
                         srcdir="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA/SCA-INF/src/soakafka"
                         destdir="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA/SCA-INF/classes"
                     includeantruntime="false">
                     <include name="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA/SCA-INF/lib/**"/>
              </javac>
            </target>
            <target name="sca-compile" depends="compile">
                <ant antfile="${middleware.home}/soa/bin/ant-sca-compile.xml" inheritAll="false">
                     <property name="scac.input" value="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA/composite.xml"/>
                </ant>
            </target>
      
            <target name="sca-package" depends="sca-compile">
                <ant antfile="/${middleware.home}/soa/bin/ant-sca-package.xml" inheritAll="false">
                     <property name="compositeDir" value="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA"/>
                    <property name="compositeName" value="SOAKafkaProducerPrj"/>
                    <property name="revision" value="${revision}"/>
                    <property name="sca.application.home" value="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj"/>
                </ant>
            </target>
      
            <target name="deploy" description="Deploy JDeveloper profiles" depends="sca-package">
              <taskdef name="ojdeploy" classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask" uri="oraclelib:OJDeployAntTask"
                       classpath="${oracle.jdeveloper.ant.library}"/>
              <ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask" executable="${oracle.jdeveloper.ojdeploy.path}"
                            ora:buildscript="${oracle.jdeveloper.deploy.dir}/ojdeploy-build.xml"
                            ora:statuslog="${oracle.jdeveloper.deploy.dir}/ojdeploy-statuslog.xml">
                <ora:deploy>
                  <ora:parameter name="workspace" value="${oracle.jdeveloper.workspace.path}"/>
                  <ora:parameter name="project" value="${oracle.jdeveloper.project.name}"/>
                  <ora:parameter name="profile" value="${oracle.jdeveloper.deploy.profile.name}"/>
                  <ora:parameter name="nocompile" value="false"/>
                  <ora:parameter name="outputfile" value="${oracle.jdeveloper.deploy.outputfile}"/>
                </ora:deploy>
              </ora:ojdeploy>
      
               <!-- Deployment SOA Suite Composite -->
              <ant antfile="/${middleware.home}/soa/bin/ant-sca-deploy.xml" target="deploy" inheritall="false">
                <property name="user"      value="${WEBLOGICUSER}"/>
                <property name="password"  value="${WEBLOGICPWD}"/>
                <property name="serverURL"     value="${WEBLOGICURL}"/>
                <property name="sarLocation"   value="${workspace}/SOAKafkaProducerApp/SOAKafkaProducerPrj/SOA/deploy/sca_SOAKafkaProducerPrj_rev${revision}.jar"/>
                <property name="overwrite"     value="true"/>
              </ant>
      
            </target>
            <target name="copy" description="Copy files to output directory" depends="init">
              <patternset id="copy.patterns">
                <include name="**/*.GIF"/>
                <include name="**/*.JPEG"/>
                <include name="**/*.JPG"/>
                <include name="**/*.PNG"/>
                <include name="**/*.cpx"/>
                <include name="**/*.dcx"/>
                <include name="**/*.ejx"/>
                <include name="**/*.gif"/>
                <include name="**/*.ini"/>
                <include name="**/*.jpeg"/>
                <include name="**/*.jpg"/>
                <include name="**/*.png"/>
                <include name="**/*.properties"/>
                <include name="**/*.sva"/>
                <include name="**/*.tag"/>
                <include name="**/*.tld"/>
                <include name="**/*.wsdl"/>
                <include name="**/*.xcfg"/>
                <include name="**/*.xlf"/>
                <include name="**/*.xml"/>
                <include name="**/*.xsd"/>
                <include name="**/*.xsl"/>
                <include name="**/*.exm"/>
                <include name="**/*.xml"/>
                <exclude name="build.xml"/>
              </patternset>
              <copy todir="${output.dir}">
                <fileset dir="SOA/SCA-INF/src">
                  <patternset refid="copy.patterns"/>
                </fileset>
                <fileset dir=".">
                  <patternset refid="copy.patterns"/>
                </fileset>
              </copy>
            </target>
          </project>
      
      
    • build.properties 檔案會決定 build.xml 配置檔案中將使用的特性。

      build.properties
      
      oracle.commons=../../../../oracle_common/
      install.dir=../../../..
      oracle.home=${env.ORACLE_HOME_SOA_12_2_1}
      oracle.jdeveloper.workspace.path=${env.WORKSPACE}/SOAKafkaProducerApp/SOAKafkaProducerApp.jws
      middleware.home=${env.MIDDLEWARE_HOME_SOA_12_2_1}
      workspace=${env.WORKSPACE}
      oracle.jdeveloper.ant.library=${env.ORACLE_HOME_SOA_12_2_1}/jdev/lib/ant-jdeveloper.jar
      oracle.jdeveloper.deploy.dir=${env.WORKSPACE}/SOAKafkaProducerApp/SOAKafkaProducerPrj/deploy
      oracle.jdeveloper.ojdeploy.path=${oracle.home}/jdev/bin/ojdeploy
      javac.nowarn=off
      oracle.jdeveloper.project.name=SOAKafkaProducerPrj
      revision=1.0
      oracle.jdeveloper.deploy.outputfile=${env.WORKSPACE}/SOAKafkaProducerApp/SOAKafkaProducerPrj/deploy/sca_${profile.name}_rev{$revision}
      output.dir=classes
      javac.deprecation=off
      oracle.jdeveloper.deploy.profile.name=*
      javac.debug=on
      WEBLOGICPWD=${env.WEBLOGICPWD}
      WEBLOGICURL=${env.WEBLOGICURL}
      WEBLOGICUSER=${env.WEBLOGICUSER}
      
      
  6. 起始測試的 SOA Suite 環境。請先開啟 SOA Suite 環境的防火牆連接埠。要發行的連接埠是 9092,代表 Oracle Streaming 或 Kafka 連接埠。

  7. 在 JDeveloper 中啟用內嵌 SOA 伺服器。

    • JDeveloper 具有用於開發和測試的整合式 SOA Suite 伺服器。它是具備實際開發 SOA 服務所需之所有功能的伺服器。您必須建立並啟用伺服器,才能使用此伺服器。

    • 若要啟動伺服器,您必須先檢視應用程式伺服器。若要這麼做,請前往「視窗」選項,然後選取應用程式伺服器,如下列影像所示。

      JDeveloper-select-app-server.png

    • 應用程式伺服器視窗會顯示在畫面左側。確定已在視窗中建立 integratedWeblogicServer。如果沒有,您必須先建立,然後加以啟用才能使用。

    • 前往執行選項,然後選取啟動伺服器執行處理,如以下影像所示。

      jdev-start-app-server.gif

    • 請輸入必要的資料以建立 WebLogic 執行處理。請寫下稍後測試需要的值。

      jdev-create-app-server.gif

    • 如果您已建立伺服器或伺服器可用,請在伺服器上按一下滑鼠右鍵,然後將其啟用,如下圖所示。

      JDeveloper-start-app-server.png

  8. 在 SOA Suite 中執行手動部署。

    • 首先,讓我們手動部署 Kafka 用戶服務 (SOAKafkaConsumerPrj)。若要這樣做,請找出您的應用程式頁籤,然後使用滑鼠右鍵開啟功能表選項,如下圖所示。

      soa-deploy-1.png

    • 選取部署選項,然後建立新的部署設定檔。您將會看到一個組態畫面,而且必須選擇設定檔類型為 SOA-SAR 檔案,因為我們將會產生一個檔案。

      soa-deploy-2.png

    • 這是為了讓我們能夠在下一個步驟中部署套裝程式的準備。在下一個畫面中,保留指定的選項,然後按一下確定

      soa-deploy-3.png

    • 再次開啟部署功能表選項。部署選項已建立且可供使用。選取它。

      soa-deploy-4.png

    • 現在,請選擇直接部署到 SOA 伺服器的選項。然後選擇如下所示的選項。

      soa-deploy-5.png

    • 保留所有提供的選項,然後選取覆寫具有相同修訂版本 ID 的所有現有複合項目。如果未勾選此選項,而您嘗試在第一次執行之後執行連續部署,將會中斷錯誤訊息。

      soa-deploy-6.png

    • 然後選取 IntegratedWeblogicServer 選項。此選項代表前一節中說明的 JDeveloper 內嵌伺服器 (如何在 JDeveloper 中啟用內嵌 SOA 伺服器)。

    • 如果您的 JDeveloper Weblogic 伺服器已順利建立並啟動,您將看到下列選項和「執行」狀態,確認所有項目都正常。如果您看不到此選項,您可能尚未建立伺服器或尚未啟動該伺服器。檢閱先前的步驟。

      soa-deploy-9.png

    • 下一步確認直到摘要畫面,然後按一下完成

    • 您可以在底部的視窗中,依循應用程式的部署。等到看到部署完成作為成功訊息為止。

      soa-deploy-11.png

  9. 在 Weblogic 中安裝 JKS 憑證。

    • 在 SSL 環境中,將需要透過適用於 WebLogic 環境的 JKS 憑證來建立安全金鑰 (公用 / 專用)。若要產生金鑰,請取得您 Oracle Cloud Streaming 執行處理的憑證並將此憑證新增至 JKS 檔案,我們將會呼叫 DemoTrust (DemoTrust.jks)。

      注意:DemoTrust.jks 檔案會加上 ALIAS 加上戳記,以及 Java 程式碼中將使用的密碼。

    • 建立 JKS 檔案之後,您可以將此檔案移至您的 WebLogic 伺服器結構中。

      1. 取得 Oracle Cloud Streaming Certificate。如需詳細資訊,請參閱 Using the Oracle Cloud Infrastructure Streaming Service Adapter with Oracle Integration Generation 2

      2. 產生 JKS 檔案。

      3. 在 Weblogic 中安裝 JKS 檔案。

        echo -n | openssl s_client -connect cell-1.streaming.us-ashburn-1.oci.oraclecloud.com:9092 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ociStreaming.cert keytool -keystore Streaming_truststore.jks -alias OSSStream -import -file ociStreaming.cert

        sudo keytool -importcert -file ociStreaming.cert -keystore DemoTrust.jks -alias "kafka" -storepass DemoTrustKeyStorePassPhrase

        例如:

        echo -n | openssl s_client -connect cell-1.streaming.us-ashburn-1.oci.oraclecloud.com:9092 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ociStreaming.cert keytool -keystore Streaming_truststore.jks -alias OSSStream -import -file ociStreaming.cert

        sudo keytool -importcert -file ociStreaming.cert -keystore DemoTrust.jks -alias "kafka" -storepass DemoTrustKeyStorePassPhrase

        • 如果您想要依別名產生或刪除金鑰存放區,請執行下列步驟:

          shell
              sudo keytool -import -v -file streaming.us-ashburn-1.oci.oraclecloud.com.cer -storepass changeit -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/jre/lib/security/cacerts -alias "kafka"
          
              sudo keytool -delete -alias kafka -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/jre/lib/security/cacerts -storepass changeit
          
              sudo keytool -import -v -file streaming.us-ashburn-1.oci.oraclecloud.com.cer -keystore DemoTrust.jks -alias "kafka" -storepass DemoTrustKeyStorePassPhrase
          
              sudo keytool -delete -alias kafka -keystore DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase
          
        • 尋找通常具有此路徑的 wlserver 資料夾:/wlserver/server/lib。例如:cd /u01/app/oracle/middleware/wlserver/server/libcd /User/u01/Oracle/Middleware/Oracle_Home/wlserver/server/lib

        • DemoTrust.jks 檔案取代為此步驟中產生的檔案。

        • 在複製 DemoTrust.jks 檔案之後,您必須變更部署檔案的目錄。建立類別時,請變更兩個專案的 /src/soakafka/KafkaExample.java 檔案 (SOAKafkaProducerprjSOAKafkaConsumerprj),如下所示:

          變更信任存放區 -soa-1.png

  10. 測試應用程式。

    • 上傳測試環境之後,您的執行處理可以在以下網址取得:http://localhost:7101/em.

    • 記住您的使用者名稱與密碼。

    • 移至 SOA 功能表項目和部署的元件選項下的應用程式。

      soa-test-5.png

    • 依據實行,填入服務所需的訊息參數。此參數稱為 "msg",訊息格式為 JSON (根據先前的步驟)。

      soa-test-producer-1a.png

    • 以 JSON 格式輸入訊息之後,請按一下「測試 Web 服務」,在訊息佇列上執行您的產生器服務。

      soa-test-producer-2.png

作業 3:在 Oracle Cloud 上建立 SOA Suite 執行處理

您必須有一個 Oracle SOA Suite 的作用中執行處理,才能部署應用程式。本教學課程中使用的執行處理是 Marketplace 上可用的映像檔,且會有堡壘主機提供的 SOA Suite 結構以保護伺服器。

  1. 就這樣,讓我們建立一個執行處理。在 Oracle Cloud 主控台中,按一下主功能表 (位於畫面左上角),選項「Marketplace」和「所有應用程式」,如下所示:

    市場 -place.png

  2. 在影像搜尋畫面中,輸入 "soa suite" 以尋找正確的影像:

    市集 -soa-suite.png

  3. 按一下「Oracle SOA Suite (BYOL)」選項即可開始建立執行處理。您將會看到一些必要的選項可供選取。如需詳細資訊,請參閱在 Oracle Cloud Infrastructure 的 Marketplace 中使用 Oracle SOA Suite

    • 確認 SOA Suite 版本:12.2.1.4 或更新版本 (此研習是以 12.2.1.4 版本開發)。

    • 選取要在其中建立 SOA Suite 執行處理的區間。

    • 確認接受授權合約的條款與條件。

    • 按一下「啟動堆疊」

      soa-suite-creation.png

  4. 從 Oracle Cloud 主控台主功能表前往「運算」和「執行處理」。

    運算 -select.png

  5. 選取您建立 SOA Suite 執行處理的區間,若選取區間,您將會看到 2 個虛擬機器。

    • SOA Suite 伺服器
    • 作為保護 SOA Suite 伺服器堡壘主機的 VM

    注意:VM 堡壘主機將會有公用 IP,之後將可開啟 IP 通道,以透過網際網路存取 SOA Suite 伺服器。

    實例 -soa-suite-compute.png

  6. 若要在 Bastion Server 與 SOA Suite 執行處理之間建立通道,您可以透過 SSH 命令進行,如下所示:

    shell
        ssh -Y -i <Arq.Chave SSH> -L <Port SOA>:<IP Instance SOA Suite>:<Port External> opc@<IP Public Bastion>
    
        Example:
        ssh -Y -i keyrvbastion.pem -L 7002:10.253.128.9:7002 opc@152.67.55.11
    
    

    透過堡壘主機建立連線之後,您可以使用 http://localhost:7002/em. 存取 Weblogic Enterprise Manager

工作 4:使用 Oracle Visual Builder Studio 自動化部署

現在讓我們自動將 SOA 實行部署到前一個步驟建立的 Weblogic 伺服器。您必須有一個 Oracle Visual Builder Studio 執行處理。Oracle Visual Builder Studio 依專案運作,因此您可以建立專案並包含將參與其執行的使用者。

您可以在本文件結尾的「相關連結」區段中找到有關作業的詳細資訊,請使用 Visual Builder Studio 搜尋「部署」。接著,依照步驟設定 Weblogic 伺服器之 SOA Suite 實行的自動建置和部署。

  1. 在 ORACLE SOA Suite 中設定 BUILD 的虛擬機器。開始設定值之前,您需要設定符合編譯 Oracle SOA Suite 專案需求的虛擬機器,您必須選取此 VM 中要安裝的正確工具。

    1. 按一下左側功能表中的組織 (Organization) ,然後按一下虛擬機器樣板 (Virtual Machine Templates)

      vbst-create-template.png

    2. 按一下建立樣板,設定可用於建立 SOA Suite 專案的工具。然後輸入「樣板」的名稱,如果需要,您可以選擇描述此樣板。別忘記選取此 VM 所在的平台。選擇 Oracle Linux 選項 (在本文件日期之前,我們有 Oracle Linux 7 ,但是您可以選取其他較新的選項。

      vbst-create-template-2.png

    3. 選取用於建置專案的所有重要元件。選擇下列所有選項。

      vbst-config-sw.png

      vbst-config-details.png

      系統會建立您的 TEMPLATE,並且在專案要求組建時,立即建立您的 VM。

    4. Oracle Visual Builder Studio 中專案的 BUILD 組態。首先,在 Oracle Visual Builder Studio 內開啟專案,在下面的範例中,按一下 CRISTIANO HOSHIKAWA PROJ

      main-visual-builder-studio.png

      • 您將會看到您的專案頁面,以及左側功能表與可用的選項,以及原始程式碼儲存區域中專案的右側,以及屬於此專案 (專案使用者) 的小組。

        視覺化產生器音訊 -project.png

    5. 按一下左側功能表上的 BUILD 選項即可檢視所有現有的設定值,然後替您的專案設定新的 BUILD。按一下建立工作 (Create Job)

      視覺化產生器 - 音訊建立 -job.png

    6. 輸入工作的名稱,並選取 VM 樣板 (在上一個階段作業中建立)。

      vbst-create-job-details.png

  2. 現在讓我們逐步設定您的專案組建。組態的第一個部分是建立之前必須使用原始程式碼建立的 Oracle SOA Suite 專案儲存區域。在本文件中,我們正與本文件 git 中提供的 SOAKafkaProducerApp 專案合作。您可以將此專案複製到 Oracle Visual Builder Studio 執行處理的 git 中。

    1. SOAKafkaProducerApp 專案複製到 Visual Builder Studio 之後,請使用 Git 儲存區域的名稱設定您的 BUILD,然後選取「自動在 SCM 確認執行組建」選項。也請檢查分支名稱是否符合您的 git 專案 。

      vbst-git.png

    2. 現在選取「參數」頁籤。您必須在右側使用「組合方塊」功能表「新增參數」來建立 3 個參數。在下方,必須建立的名稱以及在括號中,類型如下:

      • WEBLOGICUSER:Weblogic 使用者 (字串類型)

      • WEBLOGICPWD:您的 Weblogic 使用者密碼 (輸入「密碼 / 密碼」)

      • WEBLOGICURL:Weblogic 實例的 URL (字串類型)

      • 重要的觀測是,WEBLOGICURL 中的 URL 必須是 localhost,因為通道將透過堡壘主機伺服器建立

        vbst-parameters.png

    3. 現在按一下「組建前」頁籤,設定從堡壘主機伺服器到 Weblogic SOA Suite 伺服器的 SSH 通道。請記住 SSH 金鑰 (私密金鑰) 並填寫對應的欄位。填入通道組件的資料。

      • 使用者名稱:opc

      • 本機連接埠: 11002

      • 遠端主機:SOA Suite 執行處理的專用 IP

      • 遠端連接埠: 11002

      • SSH 伺服器:堡壘主機的公用 IP

      • 重要的觀察是先前已設定連接埠 11002,因此它是部署 SOA Suite 專案的存取連接埠。

        vbst-tunnel.png

    4. 按一下「步驟」頁籤,即可設定 SOA Suite 專案的 BUILD (透過 Maven) 和 DEPLOYMENT (透過 ANT)。填寫如下:

      • 馬芬
      • 目標:編譯套件

      • POM 檔案:SOAKafkaProducerApp/SOAKafkaConsumerPrj/SOA/SCA-INF/pom.xml。這是用於組合專案套件的 Maven pom.xml 檔案

      • 輸入

        • 目標:sca-package 部署

        • 組建檔案:SOAKafkaProducerApp/SOAKafkaConsumerPrj/build.xml。這是用於建置應用程式後的 Ant build.xml 檔案。

      • 特性

        • WEBLOGICUSER=${WEBLOGICUSER}

        • WEBLOGICPWD=${WEBLOGICPWD}

        • WEBLOGICURL=${WEBLOGICURL}

      重要注意事項

      • SOAKafkaProducerApp 應用程式有 2 個專案:SOAKafkaProducerPrj 和 SOAKafkaConsumerPrj。

      • 我們正在說明其中一個專案的組態。必須對其他專案執行相同的步驟。

      vbst-config-step.png

    5. 現在,讓我們完成 BUILD 組態設定。選取「建置後」頁籤。此步驟是選擇性的,不過您可能想要在執行 Maven 時產生上一個步驟所建立的使用者自建物件。針對此,請設定此步驟,以便產生使用者自建物件供之後下載。

      vbst-after-build.png

  3. 在 Oracle Visual Builder Studio 中執行 BUILD。設定之後,每當您的程式碼儲存區域 (Visual Builder Studio git) 發生確認時,就會自動啟動 BUILD。您也可以手動執行 BUILD,只需按一下 BUILD 選項即可。嘗試執行 BUILD,您可以檢查產生的日誌。

    vbst-log-1.png

    vbst-logs-3.png

    vbst-logs-2.png

確認

其他學習資源

探索 docs.oracle.com/learn 的其他實驗室,或者存取更多 Oracle Learning YouTube 頻道上的免費學習內容。此外,請瀏覽 education.oracle.com/learning-explorer 以成為 Oracle Learning 檔案總管。

如需產品文件,請造訪 Oracle Help Center