我正在使用VFS传输轮询一个简单的文本文件,然后我将文件的文本发送到队列。此流程工作正常,但如果出现错误情况,执行故障序列时,我想将我的错误消息写入一个简单的文本文件,它不工作。
注意:
我正在使用WSO2 ESB版本4.8.1。 我在我的" axis2.xml"中启用了VFS传输。文件。 我也尝试了与我有关的question中提供的所有解决方案。
我的服务代码:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FileWriteTest"
transports="vfs"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"
separator="******************FileWrite In Sequence Start*************"/>
</inSequence>
<outSequence/>
<faultSequence>
<payloadFactory media-type="xml">
<format>
<MessageFormat xmlns="">
<ECode>$1</ECode>
<EMsg>$2</EMsg>
<EDetail>$3</EDetail>
<EException>$4</EException>
</MessageFormat>
</format>
<args>
<arg evaluator="xml" expression="get-property('ERROR_CODE')"/>
<arg evaluator="xml" expression="get-property('ERROR_MESSAGE')"/>
<arg evaluator="xml" expression="get-property('ERROR_DETAIL')"/>
<arg evaluator="xml" expression="get-property('ERROR_EXCEPTION')"/>
</args>
</payloadFactory>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="ClientApiNonBlocking" scope="axis2" action="remove"/>
<send>
<endpoint>
<address uri="vfs:file:///home/omerkhalid/Documents/WSO2Test/FileWrite/Errorlog.txt"/>
</endpoint>
</send>
</faultSequence>
<endpoint>
<address uri="jms:/FileWriterResponse?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:6616&transport.jms.DestinationType=queue"/>
</endpoint>
</target>
<parameter name="transport.PollInterval">10</parameter>
<parameter name="transport.vfs.FileURI">file://home/omerkhalid/Documents/WSO2Test/FileWrite/InTest</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://home/omerkhalid/Documents/WSO2Test/FileWrite/DoneTest</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="serviceType">proxy</parameter>
<description/>
</proxy>
问题区域:
问题出在以下代码区域,我在这里定义故障序列的端点。它确实在该特定位置创建了一个文件,但该文件仍为空。
<send>
<endpoint>
<address uri="vfs:file:///home/omerkhalid/Documents/WSO2Test/FileWrite/Errorlog.txt"/>
</endpoint>
</send>
例外:
org.apache.axis2.AxisFault: The system cannot infer the transport information from the file:///home/omerkhalid/Documents/WSO2Test/FileWrite/Errorlog.txt URL.
at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:81)
at org.apache.axis2.client.OperationClient.prepareMessageContext(OperationClient.java:288)
at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:249)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:59)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:338)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:333)
at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.mediators.MediatorFaultHandler.onFault(MediatorFaultHandler.java:85)
at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:54)
at org.apache.synapse.endpoints.AbstractEndpoint.invokeNextFaultHandler(AbstractEndpoint.java:640)
at org.apache.synapse.endpoints.AbstractEndpoint.onFault(AbstractEndpoint.java:475)
at org.apache.synapse.endpoints.AddressEndpoint.onFault(AddressEndpoint.java:43)
at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:102)
at org.apache.synapse.core.axis2.AsyncCallback.onError(AsyncCallback.java:67)
at org.apache.axis2.engine.AxisEngine$TransportNonBlockingInvocationWorker.run(AxisEngine.java:643)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
答案 0 :(得分:1)
从faultsSequence更改payloadFactory中的消息:
邮件的根节点必须为:<text xmlns="http://ws.apache.org/commons/ns/payload">
此节点的内容将是发送到您文件的文本值