Spring 集成:错误通道在 XML 中不可用
Spring Integration: Error Channel not available in XML
您好,我正在使用 Spring 与 JMS 集成的集成,我注意到当我尝试在我的 jms-message-drive-outbound-adapter 中使用错误通道时,它给出以下错误;
根据我之前问题的建议,我想检索异常和回滚事务,这样我就不会丢失消息。如果无法使用错误通道,我该如何实现。
cvc-complex-type.3.2.2: Attribute 'error-channel' is not allowed to appear in element 'jms:message-driven-channel-adapter'.
我的XML如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/kafka
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd">
<jms:message-driven-channel-adapter id="requestChannelAdapter" channel="requestChannel"
container="requestListenerContainer" error-channel=""/>
<int-kafka:outbound-channel-adapter
id="kafkaOutboundChannelAdapter" kafka-template="kafkaTemplate"
auto-startup="true" sync="true" channel="inputToKafka" topic="test">
</int-kafka:outbound-channel-adapter>
</beans>
在最近的版本中它是否被其他东西取代了。
下面列出了我的 POM 文件以供参考,以防版本不匹配:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.dzone.activemq</groupId>
<artifactId>jpmc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jpmc</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-kafka</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
<!-- dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-zookeeper</artifactId>
<version>4.3.9.RELEASE</version>
</dependency-->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
可以无视;您的 IDE 似乎正在使用来自互联网的架构 - 请参阅其顶部的注释...
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
<!--
+++++ IMPORTANT +++++
This schema is for the 1.0 version of Spring Integration JMS. We cannot update it to the current schema
because that will break any applications using 1.0.3 or lower. For subsequent versions, the unversioned
schema is resolved from the classpath and obtained from the jar.
Please refer to github:
https://github.com/spring-projects/spring-integration/tree/master/spring-integration-jms/src/main/resources/org/springframework/integration/jms/config
for the latest schema.
-->
您可以忽略它,或者使用知道如何操作的 Spring-Aware IDE(Spring 工具套件 - STS、IntelliJ IDEA 等)通过 /META-INF/spring.schemas
.
在 class 路径上查找当前架构
如果您已经在使用 STS(或带有 Spring IDE 插件的 Eclipse),请务必在项目上启用 "Spring Nature"。
您好,我正在使用 Spring 与 JMS 集成的集成,我注意到当我尝试在我的 jms-message-drive-outbound-adapter 中使用错误通道时,它给出以下错误;
根据我之前问题的建议,我想检索异常和回滚事务,这样我就不会丢失消息。如果无法使用错误通道,我该如何实现。
cvc-complex-type.3.2.2: Attribute 'error-channel' is not allowed to appear in element 'jms:message-driven-channel-adapter'.
我的XML如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/kafka
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd">
<jms:message-driven-channel-adapter id="requestChannelAdapter" channel="requestChannel"
container="requestListenerContainer" error-channel=""/>
<int-kafka:outbound-channel-adapter
id="kafkaOutboundChannelAdapter" kafka-template="kafkaTemplate"
auto-startup="true" sync="true" channel="inputToKafka" topic="test">
</int-kafka:outbound-channel-adapter>
</beans>
在最近的版本中它是否被其他东西取代了。
下面列出了我的 POM 文件以供参考,以防版本不匹配:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.dzone.activemq</groupId>
<artifactId>jpmc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jpmc</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-kafka</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
<!-- dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-zookeeper</artifactId>
<version>4.3.9.RELEASE</version>
</dependency-->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
可以无视;您的 IDE 似乎正在使用来自互联网的架构 - 请参阅其顶部的注释...
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
<!--
+++++ IMPORTANT +++++
This schema is for the 1.0 version of Spring Integration JMS. We cannot update it to the current schema
because that will break any applications using 1.0.3 or lower. For subsequent versions, the unversioned
schema is resolved from the classpath and obtained from the jar.
Please refer to github:
https://github.com/spring-projects/spring-integration/tree/master/spring-integration-jms/src/main/resources/org/springframework/integration/jms/config
for the latest schema.
-->
您可以忽略它,或者使用知道如何操作的 Spring-Aware IDE(Spring 工具套件 - STS、IntelliJ IDEA 等)通过 /META-INF/spring.schemas
.
如果您已经在使用 STS(或带有 Spring IDE 插件的 Eclipse),请务必在项目上启用 "Spring Nature"。