我想通过计划任务调用代理服务,以下是我的调度程序
public class SchedularTask implements Task, ManagedLifecycle {
/**
* Synapse environment.
*/
private SynapseEnvironment synapseEnvironment;
/**
* Endpoint Url.
*/
private String endPointUrl;
/**
* Phone number.
*/
private String phoneNumber;
/**
* License key.
*/
private String licenseKey;
/**
* Initializing the Life cycle.
*/
@Override
public void init(SynapseEnvironment synapseEnvironmentParam) {
this.synapseEnvironment = synapseEnvironmentParam;
}
/**
* Executing the task.
*/
@Override
public void execute() {
MessageContext messageContext = synapseEnvironment
.createMessageContext();
messageContext.setProperty("phoneNumber", this.phoneNumber);
messageContext.setProperty("licenseKey", this.licenseKey);
messageContext.setTo(new EndpointReference(endPointUrl));
synapseEnvironment.injectMessage(messageContext);
}
/**
* Destroying.
*/
@Override
public void destroy() {
}
/**
* @return the endPointUrl
*/
public final String getEndPointUrl() {
return endPointUrl;
}
/**
* @param endPointUrl
* the endPointUrl to set
*/
public final void setEndPointUrl(final String endPointUrl) {
this.endPointUrl = endPointUrl;
}
/**
* @return the phoneNumber
*/
public final String getPhoneNumber() {
return phoneNumber;
}
/**
* @param phoneNumber
* the phoneNumber to set
*/
public final void setPhoneNumber(final String phoneNumber) {
this.phoneNumber = phoneNumber;
}
/**
* @return the licenseKey
*/
public final String getLicenseKey() {
return licenseKey;
}
/**
* @param licenseKey
* the licenseKey to set
*/
public final void setLicenseKey(final String licenseKey) {
this.licenseKey = licenseKey;
}
}
我将endpoinUrl作为http://{ip}:8290/services/a
传递,它是名为a
的代理服务的端点。
但我在esb控制台中找不到任何自定义日志,我按顺序放置了代理服务,(这意味着没有命中代理服务) 但是在esb控制台
中有一个日程安排的任务,如下所示[2015-03-21 18:15:18,934] INFO - LogMediator To: http://{ip}:8290/services/a, MessageID: urn:uuid:c527c357-564f-4b58-804e-54e8e7a6a3f5, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body></soapenv:Body></soapenv:Envelope>
而且我尝试在调度程序中使用日志记录,我尝试了log4j和apache commons,但它没有用。是否有任何配置来激活日志记录。
答案 0 :(得分:0)
您可以使用代理检查以下示例调度程序任务。
<task name="SampleInjectToProxyTask"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger count="5" interval="5"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="soapAction"
value="getQuote"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="format"
value="soap11"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="injectTo"
value="proxy"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<m0:getQuote xmlns:m0="http://services.samples">
<m0:request>
<m0:symbol>IBM</m0:symbol>
</m0:request>
</m0:getQuote>
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="proxyName"
value="testProxy"/>
</task>
<proxy name="testProxy"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<send >
<endpoint key="StockQuoteEpr"/>
</send>
</inSequence>
</target>
</proxy>
<endpoint name="StockQuoteEpr">
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
<sequence name="main">
<in>
<log level="full"/>
<filter source="get-property('To')" regex="http://localhost:9000.*">
<send/>
</filter>
</in>
<out>
<send/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
</endpoint>