骡 - 直到成功抛出异常 [英] Mule - Throw Exception with until-successful

查看:140
本文介绍了骡 - 直到成功抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的骡子流程:

HTTP => 记录器 => =>直到成功[ JAVA ] => LOGGER

HTTP => Logger => SOAP (CXF) => Until Successful [JAVA] => LOGGER



Spring :

<spring:beans>
    <spring:bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <spring:property name="locations">
            <spring:list>
                <spring:value>test.properties</spring:value>
            </spring:list>
        </spring:property>
    </spring:bean>
    <spring:bean id="testIntegration"
        class="x.x.x.IntegrationClass" init-method="init">
        <spring:property name="url" value="${destiny.url}" />
        <spring:property name="username" value="${message.username}" />
        <spring:property name="password" value="${message.password}" />
    </spring:bean>
</spring:beans>

流量:

    <http:inbound-endpoint exchange-pattern="request-response"
        host="localhost" port="8087" doc:name="HTTP" />
    <logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>

    <cxf:jaxws-service doc:name="Test service"
        serviceClass="dynamics.file.request.Requests" />

    <until-successful maxRetries="3"
        secondsBetweenRetries="60" doc:name="Until Successful" synchronous="true">
        <component doc:name="Java">
            <spring-object bean="testIntegration" />
        </component>
    </until-successful>
    <logger message="#[message.payloadAs(java.lang.String)]" level="INFO"
        doc:name="Logger" />
</flow>

Java组件返回一个String(XML而是String),当我使用直到成功它显示我这个错误:

The Java component returns a String (XML but String) and when I use until-successful it shows me this error:

Exception thrown inside until-successful org.mule.component.ComponentException: Component that caused exception is: DefaultJavaComponent{Flow_test.component.1805940825}. Message payload is of type: String

[[test_flow].connector.http.mule.default.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: 

********************************************************************************
Message               : Failed to find entry point for component, the following resolvers tried but failed: [
MethodHeaderPropertyEntryPointResolver: The required property "method" is not set on the event
CallableEntryPointResolver: Object "es.test.integration.testIntegration@4eb6b10c" does not implement required interface "interface org.mule.api.lifecycle.Callable"
ReflectionEntryPointResolver: Found too many possible methods on object "es.test.integration.testIntegration" that accept parameters "{class java.lang.String}", Methods matched are "[public java.lang.String es.test.integration.testIntegration.cte(java.lang.String), public java.lang.String es.test.integration.testIntegration.cancelCte(java.lang.String), public java.lang.String es.test.integration.testIntegration.newCte(java.lang.String), public java.lang.String es.test.integration.testIntegration.totalCte(java.lang.String), public java.lang.String es.test.integration.testIntegration.resultCte(java.lang.String), public java.lang.String es.test.integration.testIntegration.newCte(java.lang.String), public java.lang.String es.test.integration.testIntegration.cteAll(java.lang.String)]"
AnnotatedEntryPointResolver: Component: es.test.integration.testIntegration@4eb6b10c doesn't have any annotated methods, skipping.
]
Code                  : MULE_ERROR-321

    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:49)
    at org.mule.component.DefaultComponentLifecycleAdapter.invoke(DefaultComponentLifecycleAdapter.java:339)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:82)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************







Message               : Software caused connection abort: socket write error (java.net.SocketException)
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Software caused connection abort: socket write error (java.net.SocketException)
  java.net.SocketOutputStream:-2 (null)
2. Software caused connection abort: socket write error (java.net.SocketException) (org.mule.api.DefaultMuleException)
  org.mule.transport.http.HttpMessageProcessTemplate:170 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

有了这个错误我想我需要任何参数,但如果我纠正我'm wrong:

With that error I suppose that I need any parameters here but correct me if I'm wrong:

public void init()
{

    NtlmAuthenticator authenticator = new NtlmAuthenticator(username,password);
    Authenticator.setDefault(authenticator);

    Requestsservice = new Requests();
    clntprt = service.getSolicitudesPort();

    Client client = ClientProxy.getClient(cliente);
    HTTPConduit http = (HTTPConduit) client.getConduit();

    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setAllowChunking(false);

    http.setClient(httpClientPolicy);

    BindingProvider provider = (BindingProvider) clntprt;
    provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                    url);
}

更新:

我有init方法我有实现的方法(这两个例子,但还有更多):

Where I have the init method I have the implemented methods (These both for example, but there are more):

@WebMethod(operationName = "CancelCte", action = "urn:microsoft-dynamics-schemas/codeunit/Requests:CancelCte")
@RequestWrapper(localName = "CancelCte", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests", className = "x.x.Requests.CancelCte")
@ResponseWrapper(localName = "CancelCte_Result", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests", className = "x.x.Requests.CancelCteResult")
@WebResult(name = "return_value", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests")
public String CancelCte(
        @WebParam(name = "xmlInput", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests") String xmlInput) 
{
    return client.CancelCte(xmlInput);
}

@WebMethod(operationName = "newCte", action = "urn:microsoft-dynamics-schemas/codeunit/Requests:newCte")
@RequestWrapper(localName = "newCte", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests", className = "x.x.Requests.newCte")
@ResponseWrapper(localName = "newCte_Result", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests", className = "x.x.Requests.newCteResult")
@WebResult(name = "return_value", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests")
public String newCte(
        @WebParam(name = "xmlInput", targetNamespace = "urn:microsoft-dynamics-schemas/codeunit/Requests") String xmlInput) 
{
    return client.newCte(xmlInput);
}

像现在一样,自动使用必要的方法。

Like now, automatically use the necessary method.

推荐答案

使用您提供的部分信息,我可以说的是,问题的根源在于:

With the partial information you have provided, all I can say is that the source of the problem is located in:

<spring-object bean="testIntegration" />

基于:导致异常的组件是:DefaultJavaComponent {Flow_test.component。 1805940825}

主要问题是Mule找不到一个方法来调用自定义组件:有两种方式1,采取 String ,这可以防止Mule选择适当的入口点。解决这个问题的两个解决方案:

The main issue is that Mule can't locate a method to call on your custom component: there are two many methods of arity 1 that take String, which prevent Mule to pick an appropriate "entry point". Two solutions to fix this:


  • 使用方法名称设置名为方法的属性在调用组件之前调用其值,

  • 使用调用消息处理器直接调用所需的方法。 li>
  • Set a property named method with the method name to call as its value before the call to the component,
  • Use the invoke message processor to call the desired method directly.

作为旁注,似乎这个组件执行出站HTTP调用:通常你想使用Mule HTTP来做这个而不是在自定义代码。首先,您将这些交互嵌入到自定义代码中:某人看着Mule配置不会知道出站HTTP呼叫涉及。此外,Mule本身也不会知道它无法像这样的自定义HTTP调用中的一般生命周期和错误管理,统计信息等。

As a side note, it seems this component performs outbound HTTP calls: typically you want to use Mule HTTP to do this instead of doing it in custom code. First you're burying these interactions inside custom code: someone looking at the Mule config won't know that outbound HTTP call are involved. Moreover, Mule itself will not know so it can't do anything like general lifecycle and error management, stats... on these custom HTTP calls.

这篇关于骡 - 直到成功抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆