Spring 集成错误 - Dispatcher 没有频道订阅者
Spring Integration Error - Dispatcher has no subscribers for channel
获取错误,
org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.web.context.WebApplicationContext:.myGatewayChannel'.
Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
代码,
import javax.jms.ConnectionFactory;
import org.apache.activemq.jms.pool.PooledConnectionFactory;
import org.apache.activemq.spring.ActiveMQConnectionFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.jms.JmsOutboundGateway;
@Component
public class MyOutboundGateway
{
@ServiceActivator(inputChannel = "myGatewayChannel")
public JmsOutboundGateway jmsGateway()
{
final JmsOutboundGateway jmsOutboundGateway = new JmsOutboundGateway();
jmsOutboundGateway.setConnectionFactory(this.getConnectionFactory());
final ExpressionParser parser = new SpelExpressionParser();
final Expression requestDestinationExpression = parser.parseExpression("payload.requestQueue");
jmsOutboundGateway.setRequestDestinationExpression(requestDestinationExpression);
final Expression replyDestinationExpression = parser.parseExpression("payload.responseQueue");
jmsOutboundGateway.setReplyDestinationExpression(replyDestinationExpression);
// jmsOutboundGateway.setCorrelationKey("JMSCorrelationID");
jmsOutboundGateway.setExtractRequestPayload(true);
return jmsOutboundGateway;
}
public ConnectionFactory getConnectionFactory()
{
final String brokerUrl = "tcp://localhost:61616";
final ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
activeMQConnectionFactory.setBrokerURL(brokerUrl);
final PooledConnectionFactory connectionFactory = new PooledConnectionFactory();
connectionFactory.setCreateConnectionOnStartup(false);
connectionFactory.setMaxConnections(1);
connectionFactory.setMaximumActiveSessionPerConnection(1);
connectionFactory.setIdleTimeout(10);
connectionFactory.setConnectionFactory(activeMQConnectionFactory);
return connectionFactory;
}
}
我的spring-context.xml,
<int:channel id="myGatewayChannel" />
<int:gateway id="myMessageServiceGateway"
service-interface="MyMessageServiceGateway"
default-request-channel="myGatewayChannel" />
我正在使用以下 pom 依赖项,
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
你能帮我解决这个问题吗?
它的 JmsOutboundGateway
和 ConnectionFactory
必须声明为 beans。
即使 MyOutboundGateway
作为组件扫描,也不能保证 @ServiceActivator
为 myGatewayChannel
填充正确的端点。
请修改您的体系结构并检查您是否真的有 <context:component-scan>
来填充 @Component
和类似的 bean。
获取错误,
org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.web.context.WebApplicationContext:.myGatewayChannel'.
Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
代码,
import javax.jms.ConnectionFactory;
import org.apache.activemq.jms.pool.PooledConnectionFactory;
import org.apache.activemq.spring.ActiveMQConnectionFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.jms.JmsOutboundGateway;
@Component
public class MyOutboundGateway
{
@ServiceActivator(inputChannel = "myGatewayChannel")
public JmsOutboundGateway jmsGateway()
{
final JmsOutboundGateway jmsOutboundGateway = new JmsOutboundGateway();
jmsOutboundGateway.setConnectionFactory(this.getConnectionFactory());
final ExpressionParser parser = new SpelExpressionParser();
final Expression requestDestinationExpression = parser.parseExpression("payload.requestQueue");
jmsOutboundGateway.setRequestDestinationExpression(requestDestinationExpression);
final Expression replyDestinationExpression = parser.parseExpression("payload.responseQueue");
jmsOutboundGateway.setReplyDestinationExpression(replyDestinationExpression);
// jmsOutboundGateway.setCorrelationKey("JMSCorrelationID");
jmsOutboundGateway.setExtractRequestPayload(true);
return jmsOutboundGateway;
}
public ConnectionFactory getConnectionFactory()
{
final String brokerUrl = "tcp://localhost:61616";
final ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
activeMQConnectionFactory.setBrokerURL(brokerUrl);
final PooledConnectionFactory connectionFactory = new PooledConnectionFactory();
connectionFactory.setCreateConnectionOnStartup(false);
connectionFactory.setMaxConnections(1);
connectionFactory.setMaximumActiveSessionPerConnection(1);
connectionFactory.setIdleTimeout(10);
connectionFactory.setConnectionFactory(activeMQConnectionFactory);
return connectionFactory;
}
}
我的spring-context.xml,
<int:channel id="myGatewayChannel" />
<int:gateway id="myMessageServiceGateway"
service-interface="MyMessageServiceGateway"
default-request-channel="myGatewayChannel" />
我正在使用以下 pom 依赖项,
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
你能帮我解决这个问题吗?
它的 JmsOutboundGateway
和 ConnectionFactory
必须声明为 beans。
即使 MyOutboundGateway
作为组件扫描,也不能保证 @ServiceActivator
为 myGatewayChannel
填充正确的端点。
请修改您的体系结构并检查您是否真的有 <context:component-scan>
来填充 @Component
和类似的 bean。