1

I try to use the next case with Apache Camel framework:

  1. Get the CSV file
  2. Split data and send it to the queue
  3. 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

Valentyn Hruzytskyi
  • 1,772
  • 5
  • 27
  • 59

0 Answers0