Spring integration 将2/n个(多个)参数传递给';intjdbc:storageproc出站网关&x27;

Spring integration 将2/n个(多个)参数传递给';intjdbc:storageproc出站网关&x27;,spring-integration,Spring Integration,嗨,伙计们,我需要帮助:) 以前,当我尝试只传递一个变量时,它工作正常。现在,当我试图通过使用Spring集成传递2/n个参数时,就会出现以下“有效载荷”异常,我对此并不清楚 我得到的例外情况如下: [2014-10-31 12:12:43,943][WARN ]GatewayProxyFactoryBean$MethodInvocationGateway.doSendAndReceive: failure occurred in gateway sendAndReceive org.sprin

嗨,伙计们,我需要帮助:)

以前,当我尝试只传递一个变量时,它工作正常。现在,当我试图通过使用Spring集成传递2/n个参数时,就会出现以下“有效载荷”异常,我对此并不清楚

我得到的例外情况如下:

[2014-10-31 12:12:43,943][WARN ]GatewayProxyFactoryBean$MethodInvocationGateway.doSendAndReceive: failure occurred in gateway sendAndReceive
org.springframework.messaging.converter.MessageConversionException: failed to convert object to Message
    at org.springframework.integration.support.converter.SimpleMessageConverter.toMessage(SimpleMessageConverter.java:85)
    at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:112)
    at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:103)
...

Caused by: org.springframework.messaging.MessagingException: At most one parameter (or expression via method-level @Payload) may be mapped to the payload or Message. Found more than one on method [public abstract java.util.List com.dao.PersonalinfoDao.queryExecute(java.lang.String,java.lang.String)]
    at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.throwExceptionForMultipleMessageOrPayloadParameters(GatewayMethodInboundMessageMapper.java:235)
    at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper.access$400(GatewayMethodInboundMessageMapper.java:77)
    at org.springframework.integration.gateway.GatewayMethodInboundMessageMapper$DefaultMethodArgsMessageMapper.toMessage(GatewayMethodInboundMessageMapper.java:337)
...
下面显示了我在传递2个参数时所做的操作:

在我的
PersonalinfoDao.java
文件中,我有以下内容:

public interface PersonalinfoDao {
/** Method to call a SQL query using spring integration mechanism */    
public List<PersonalInfo> queryExecute(String firstname, String lastname);
public class PersonalinfoService {

@Autowired
private PersonalinfoDao personalinfoDao;

public List<PersonalInfo> dbConnect(String firstname, String lastname) {
    List<PersonalInfo> personalinfoList = personalinfoDao.queryExecute(firstname, lastname);        
    return personalinfoList;
}
}

在网关定义文件中,我有以下内容:

<!-- Mapper Declarations -->    
<bean id="personalinfoMapper" class="com.support.PersonalinfoMapper"/> 

<!-- Service Inheritance -->
<bean id="personalinfoService" class="com.service.PersonalinfoService"/>

<!-- Channels = For calling DAO interface methods in Spring Integration Mechanism one has to create request & response channels --> 
<int:channel id="procedureRequestChannel"/>

<!-- Gateway = DAO Interface Method Mapped to Request & Response Channels -->   
<int:gateway id="gateway_personalinfo" default-request-timeout="5000"
             default-reply-timeout="5000"
             service-interface="com.dao.PersonalinfoDao">
    <int:method name="queryExecute" request-channel="procedureRequestChannel" />
</int:gateway>

<!-- Stored Procedure Outbound-Gateway = To call a database stored procedure -->        
<int-jdbc:stored-proc-outbound-gateway  id="outbound-gateway-storedproc-personalinfo"
                                        request-channel="procedureRequestChannel"
                                        data-source="dataSource"
                                        stored-procedure-name="pkg_personalinfo_spring.proc_personalinfo_spring"
                                        expect-single-result="true"
                                        ignore-column-meta-data="true">
    <!-- Parameter Definitions -->                                      
    <int-jdbc:sql-parameter-definition  name="firstname" direction="IN"/>
    <int-jdbc:sql-parameter-definition  name="lastname" direction="IN"/>
    <int-jdbc:sql-parameter-definition name="get_ResultSet" type="#{T(oracle.jdbc.OracleTypes).CURSOR}" direction="OUT"/>

    <!-- Parameter Mappings Before Passing & Receiving -->                              
    <int-jdbc:parameter name="firstname" expression="payload"/>
    <int-jdbc:parameter name="lastname" expression="payload"/>
    <int-jdbc:returning-resultset name="get_ResultSet" row-mapper="com.support.PersonalinfoMapper"/>

</int-jdbc:stored-proc-outbound-gateway>

我知道我在使用
expression=“payload”
时在上述网关定义中犯了错误,因为对于任何给定的Getway,我只能使用一个
有效负载。但是,由于我不清楚如何使用Map/Array/List来实现这一点,任何一个plz都能帮助我解决这个问题吗


非常感谢:)

最简单的方法可能是使用
@Payload
注释:

public interface PersonalinfoDao {

    /** Method to call a SQL query using spring integration mechanism */    
    @Payload("#args")
    public List<PersonalInfo> queryExecute(String firstname, String lastname);    

}
公共接口PersonalinfoDao{
/**方法使用spring集成机制调用SQL查询*/
@有效载荷(“args”)
公共列表查询执行(stringfirstname、stringlastname);
}
或者在
方法的XML声明中使用
有效负载表达式=“#args”


然后,框架将使有效负载成为
对象[]
,您可以在表达式中使用
有效负载[0]
有效负载[1]
等。

非常感谢您。实际上,我在我的接口类中使用了@Payload注释,正如u所建议的,后来在XML中使用了Payload[0],Payload[1]…现在它工作得非常好:)