Assets Proxy開發 assets-proxy-development

Adobe Experience Manager Assets使用Proxy來分配特定工作的處理。

Proxy是一種特定(有時是獨立的) Experience Manager執行個體,它使用Proxy背景工作器作為負責處理工作並建立結果的處理器。 Proxy Worker可用於多種任務。 如果有Assets Proxy,這可用來載入資產,以便在Assets中呈現。 例如,IDS Proxy背景工作使用Adobe InDesign伺服器來處理檔案以用於Assets。

當Proxy是單獨的Experience Manager執行個體時,這有助於減少Experience Manager編寫執行個體的負載。 根據預設,Assets會在相同的JVM中執行資產處理工作(透過Proxy外部化),以減少Experience Manager編寫執行個體的負載。

Proxy (HTTP存取) proxy-http-access

Proxy可透過HTTP Servlet使用,當它設定為接受處理工作於: /libs/dam/cloud/proxy時。 此servlet會根據發佈的引數建立Sling作業。 然後,這會新增至Proxy工作佇列,並連線至適當的Proxy背景工作。

支援的作業 supported-operations

  • job

    需求:引數jobevent必須設定為序列化值對應。 這可用來建立工作處理器的Event

    結果:新增工作。 如果成功,則會傳回唯一的工作ID。

curl -u admin:admin -F":operation=job" -F"someproperty=xxxxxxxxxxxx"
    -F"jobevent=serialized value map" http://localhost:4502/libs/dam/cloud/proxy
  • result

    需求:必須設定引數jobid

    Result: Returns a JSON representation of the result Node as created by the job processor.

curl -u admin:admin -F":operation=result" -F"jobid=xxxxxxxxxxxx"
    http://localhost:4502   /libs/dam/cloud/proxy
  • resource

    Requirements: the parameter jobid must be set.

    Result: Returns a resource associated with the given job.

curl -u admin:admin -F":operation=resource" -F"jobid=xxxxxxxxxxxx"
    -F"resourcePath=something.pdf" http://localhost:4502/libs/dam/cloud/proxy
  • remove

    Requirements: the parameter jobid must be set.

    Results: Removes a job if found.

curl -u admin:admin -F":operation=remove" -F"jobid=xxxxxxxxxxxx"
    http://localhost:4502/libs/dam/cloud/proxy

Proxy Worker proxy-worker

A proxy worker is a processor responsible for handling a job and creating a result. Workers reside on the proxy instance and must implement sling JobProcessor to be recognized as a proxy worker.

NOTE
The worker must implement sling JobProcessor to be recognized as a proxy worker.

Client API client-api

JobService is available as an OSGi service that provides methods to create jobs, remove jobs and to get results from those jobs. The default implementation of this service (JobServiceImpl) uses the HTTP client to communicate with the remote proxy servlet.

The following is an example of API usage:

@Reference
 JobService proxyJobService;

 // to create a job
 final Hashtable props = new Hashtable();
 props.put("someproperty", "some value");
 props.put(JobUtil.PROPERTY_JOB_TOPIC, "myworker/job"); // this is an identifier of the worker
 final String jobId = proxyJobService.addJob(props, new Asset[]{asset});

 // to check status (returns JobService.STATUS_FINISHED or JobService.STATUS_INPROGRESS)
 int status = proxyJobService.getStatus(jobId)

 // to get the result
 final String jsonString = proxyJobService.getResult(jobId);

 // to remove job and cleanup
 proxyJobService.removeJob(jobId);

Cloud Service configurations cloud-service-configurations

Both proxy and proxy worker configurations are available via cloud services configurations as accessible from the Assets Tools console or under /etc/cloudservices/proxy. Each proxy worker is expected to add a node under /etc/cloudservices/proxy for worker specific configuration details (for example, /etc/cloudservices/proxy/workername).

The following is an example of API usage:

@Reference(policy = ReferencePolicy.STATIC)
 ProxyConfig proxyConfig;

 // to get proxy config
 Configuration cloudConfig = proxyConfig.getConfiguration();
 final String value = cloudConfig.get("someProperty", "defaultValue");

 // to get worker config
 Configuration cloudConfig = proxyConfig.getConfiguration("workername");
 final String value = cloudConfig.get("someProperty", "defaultValue");

Developing a Customized Proxy Worker developing-a-customized-proxy-worker

The IDS proxy worker is an example of a Assets proxy worker that is already provided out-of-the-box to outsource the processing of InDesign assets.

You can also develop and configure your own Assets proxy worker to create a specialized worker to dispatch and outsource your Assets processing tasks.

Setting up your own custom proxy worker requires you to:

  • Set up and implement (using Sling eventing):

    • a custom job topic
    • a custom job event handler
  • 然後使用JobService API來:

    • 將您的自訂工作分派給Proxy
    • 管理您的工作
  • 如果您想要使用工作流程的Proxy,您必須使用WorkflowExternalProcess API和JobService API實作自訂外部步驟。

以下圖表和步驟詳細說明如何繼續:

chlimage_1-249

NOTE
在下列步驟中,InDesign的對等項會以參考範例表示。
  1. 已使用Sling工作,因此您需要為使用案例定義工作主題。

    例如,請參閱IDSJob.IDS_EXTENDSCRIPT_JOB以取得IDS Proxy背景工作。

  2. 外部步驟會用於觸發事件,然後等待直到完成;這是透過輪詢ID來完成。 開發您自己的步驟來實作新功能。

    實作WorkflowExternalProcess,然後使用JobService API和您的工作主題來準備工作事件,並將其分派到JobService (OSGi服務)。

    例如,請參閱INDDMediaExtractProcess.java以取得IDS Proxy背景工作。

  3. 實作您主題的工作處理常式。 此處理常式需要開發,以便執行您的特定動作,並被視為背景工作實作。

    例如,請參閱IDSJobProcessor.java以取得IDS Proxy背景工作。

  4. 在dam-commons中使用ProxyUtil.java。 這可讓您使用dam Proxy將工作分派給背景工作。

NOTE
Assets Proxy架構未提供現成可用的是集區機制。
InDesign整合允許存取InDesign部伺服器(IDSPool)的集區。 此集區專屬於InDesign整合,不是Assets Proxy架構的一部分。
NOTE
結果的同步化:
如果有n個執行個體使用相同的Proxy,處理結果會保留在Proxy。 使用者端(Experience Manager作者)的作業是使用建立作業時提供給使用者端的相同唯一作業ID來請求結果。 Proxy只會讓工作完成,並讓結果準備好進行要求。
recommendation-more-help
19ffd973-7af2-44d0-84b5-d547b0dffee2