Apache骆驼错误:由于以下原因未能提取身体:
我尝试使用Apache Camel框架的下一个情况:
- 获取CSV文件
- 拆分数据,然后将其发送到队列中的排列
- 数据中,从队列
CSV文件中接收到数据:
"id","from","to","conversionMultiple"
"1001","USD","INR","70"
"1002","EUR","INR","80"
"1003","AUD","INR","10"
队列创建:
from(csvFolder)
.unmarshal().csv()
.split(body())
.log("${body}") // <---- (1)
.to(QUEUE_NAME);
队列接收:
from(QUEUE_NAME) // <----------- (2)
.log("${body}");
因此,拆分后的身体(1)看起来像这样。 (四个不同的消息):
2022-05-09 21:32:58.499 INFO 16999 --- [ile://files/csv] route1 : id,from,to,conversionMultiple
2022-05-09 21:32:58.631 INFO 16999 --- [ile://files/csv] route1 : 1001,USD,INR,70
2022-05-09 21:32:58.677 INFO 16999 --- [ile://files/csv] route1 : 1002,EUR,INR,80
2022-05-09 21:32:58.694 INFO 16999 --- [ile://files/csv] route1 : 1003,AUD,INR,10
消息成功传递给队列,但是,当我尝试从队列(2)接收数据时,我收到了错误:
> 2022-05-09 21:32:58.727 WARN 71292 --- [emq-json-queue]]
> o.a.c.c.jms.EndpointMessageListener : Execution of JMS message
> listener failed. Caused by: [org.apache.camel.RuntimeCamelException -
> Failed to extract body due to: javax.jms.JMSException: Failed to build
> body from content. Serializable class not available to broker. Reason:
> java.lang.ClassNotFoundException: Forbidden class java.util.ArrayList!
> This class is not trusted to be serialized as ObjectMessage payload.
> Please take a look at http://activemq.apache.org/objectmessage.html
> for more information on how to configure trusted classes.. Message:
> ActiveMQObjectMessage {commandId = 12, responseRequired = true,
> messageId = ID:C11852-54716-1652027839908-1:1:1:1:8,
> originalDestination = null, originalTransactionId = null, producerId =
> ID:C11852-54716-1652027839908-1:1:1:1, destination =
> queue://my-activemq-json-queue, transactionId = null, expiration = 0,
> timestamp = 1652121178695, arrival = 0, brokerInTime = 1652121178697,
> brokerOutTime = 1652121178721, correlationId = null, replyTo = null,
> persistent = true, type = null, priority = 4, groupID = null,
> groupSequence = 0, targetConsumerId = null, compressed = false, userID
> = null, content = org.apache.activemq.util.ByteSequence@10f189a5, marshalledProperties = org.apache.activemq.util.ByteSequence@3f4a693f,
> dataStructure = null, redeliveryCounter = 0, size = 0, properties =
> {CamelFileLastModified=1611144622000, CamelFileParent=files/csv,
> CamelMessageTimestamp=1611144622000, CamelFilePath=files/csv/data.csv,
> CamelFileNameConsumed=data.csv, CamelFileLength=109,
> CamelFileRelativePath=data.csv, CamelFileAbsolute=false,
> CamelFileAbsolutePath=/Users/vhruzytskyi/IdeaProjects/camel-microservice-a/files/csv/data.csv,
> CamelFileName=data.csv, CamelFileNameOnly=data.csv},
> readOnlyProperties = true, readOnlyBody = true, droppable = false,
> jmsXGroupFirstForConsumer = false}]
build.gradle:
plugins {
id 'org.springframework.boot' version '2.6.7'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.education'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
ext{
camelVersion='3.16.0'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.apache.camel.springboot:camel-spring-boot-starter:$camelVersion"
implementation group: 'org.apache.camel.springboot', name: 'camel-activemq-starter', version: camelVersion
implementation group: 'org.apache.camel.springboot', name: 'camel-kafka-starter', version: camelVersion
implementation group: 'org.apache.camel.springboot', name: 'camel-http-starter', version: camelVersion
implementation group: 'org.apache.camel.springboot', name: 'camel-csv-starter', version: camelVersion
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
,为什么我在拆分后无法接收消息?
ps 我成功地收到数据而无需分裂,因此所有设置都是正确的
I try to use the next case with Apache Camel framework:
- Get the CSV file
- Split data and send it to the queue
- Recieve data from the queue
Csv file:
"id","from","to","conversionMultiple"
"1001","USD","INR","70"
"1002","EUR","INR","80"
"1003","AUD","INR","10"
Queue creation:
from(csvFolder)
.unmarshal().csv()
.split(body())
.log("${body}") // <---- (1)
.to(QUEUE_NAME);
Queue receiving:
from(QUEUE_NAME) // <----------- (2)
.log("${body}");
So, the body after splitting (1) looks like this (four different messages):
2022-05-09 21:32:58.499 INFO 16999 --- [ile://files/csv] route1 : id,from,to,conversionMultiple
2022-05-09 21:32:58.631 INFO 16999 --- [ile://files/csv] route1 : 1001,USD,INR,70
2022-05-09 21:32:58.677 INFO 16999 --- [ile://files/csv] route1 : 1002,EUR,INR,80
2022-05-09 21:32:58.694 INFO 16999 --- [ile://files/csv] route1 : 1003,AUD,INR,10
Messages passed to the queue successfully, but, when I try to receive data from the queue (2) I got the error:
> 2022-05-09 21:32:58.727 WARN 71292 --- [emq-json-queue]]
> o.a.c.c.jms.EndpointMessageListener : Execution of JMS message
> listener failed. Caused by: [org.apache.camel.RuntimeCamelException -
> Failed to extract body due to: javax.jms.JMSException: Failed to build
> body from content. Serializable class not available to broker. Reason:
> java.lang.ClassNotFoundException: Forbidden class java.util.ArrayList!
> This class is not trusted to be serialized as ObjectMessage payload.
> Please take a look at http://activemq.apache.org/objectmessage.html
> for more information on how to configure trusted classes.. Message:
> ActiveMQObjectMessage {commandId = 12, responseRequired = true,
> messageId = ID:C11852-54716-1652027839908-1:1:1:1:8,
> originalDestination = null, originalTransactionId = null, producerId =
> ID:C11852-54716-1652027839908-1:1:1:1, destination =
> queue://my-activemq-json-queue, transactionId = null, expiration = 0,
> timestamp = 1652121178695, arrival = 0, brokerInTime = 1652121178697,
> brokerOutTime = 1652121178721, correlationId = null, replyTo = null,
> persistent = true, type = null, priority = 4, groupID = null,
> groupSequence = 0, targetConsumerId = null, compressed = false, userID
> = null, content = org.apache.activemq.util.ByteSequence@10f189a5, marshalledProperties = org.apache.activemq.util.ByteSequence@3f4a693f,
> dataStructure = null, redeliveryCounter = 0, size = 0, properties =
> {CamelFileLastModified=1611144622000, CamelFileParent=files/csv,
> CamelMessageTimestamp=1611144622000, CamelFilePath=files/csv/data.csv,
> CamelFileNameConsumed=data.csv, CamelFileLength=109,
> CamelFileRelativePath=data.csv, CamelFileAbsolute=false,
> CamelFileAbsolutePath=/Users/vhruzytskyi/IdeaProjects/camel-microservice-a/files/csv/data.csv,
> CamelFileName=data.csv, CamelFileNameOnly=data.csv},
> readOnlyProperties = true, readOnlyBody = true, droppable = false,
> jmsXGroupFirstForConsumer = false}]
build.gradle:
plugins {
id 'org.springframework.boot' version '2.6.7'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.education'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
ext{
camelVersion='3.16.0'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.apache.camel.springboot:camel-spring-boot-starter:$camelVersion"
implementation group: 'org.apache.camel.springboot', name: 'camel-activemq-starter', version: camelVersion
implementation group: 'org.apache.camel.springboot', name: 'camel-kafka-starter', version: camelVersion
implementation group: 'org.apache.camel.springboot', name: 'camel-http-starter', version: camelVersion
implementation group: 'org.apache.camel.springboot', name: 'camel-csv-starter', version: camelVersion
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
So, why I can't receive messages after splitting?
PS
I successfully receive data without splitting, so all settings are correct
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论