为什么即使在我指定之后我也会收到以下异常requires-reply="false"
例外
org.springframework.integration.support.channel.ChannelResolutionException:没有可用的输出通道或replyChannel标头
配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd">
<int:channel id="inChannel">
</int:channel>
<bean id="upperService" class="sipackage.service.UppercaseService"></bean>
<int:service-activator requires-reply="false" input-channel="inChannel" ref="upperService" method="toUpper"></int:service-activator>
</beans>
JUnit
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/META-INF/spring/integration/sample.xml"})
public class ChannelTest {
@Autowired MessageChannel inChannel;
@Test
public void test() {
boolean sendOutcome=inChannel.send(MessageBuilder.withPayload("Hello, there 1!").build());
assertTrue(sendOutcome);
sendOutcome=inChannel.send(MessageBuilder.withPayload("Hello, there 2!").build());
assertTrue(sendOutcome);
}
}
服务
public class UppercaseService {
public String toUpper(String msg)
{
return msg.toUpperCase();
}
}