Uploaded image for project: 'Fuse/AMQ Documentation'
  1. Fuse/AMQ Documentation
  2. FUSEDOC-4739

Example in avro-serialize-action kamelet throws "String cannot be cast to class org.apache.avro.generic.IndexedRecord"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • camel-k-1.6
    • None
    • Camel K, Kamelets
    • None
    • integration-doc-2021-11-15
    • 2
    • Hide

      On OCP 4.9, with Camel K operator 1.4 or 1.6

      Show
      On OCP 4.9, with Camel K operator 1.4 or 1.6

      Example avro-serialize-action-binding throws error:

      [1] 2021-11-03 09:28:56,460 ERROR [org.apa.cam.pro.err.DefaultErrorHandler] (Camel (camel-1) thread #0 - timer://tick) Failed delivery for (MessageId: 3189F24F9AC9C13-0000000000000026 on ExchangeId: 3189F24F9AC9C13-0000000000000026). Exhausted after delivery attempt: 1 caught: com.fasterxml.jackson.databind.JsonMappingException: class java.lang.String cannot be cast to class org.apache.avro.generic.IndexedRecord
      

      The "timer-source" kamelet produces String message which can't be cast to avro format expected by first step action kamelet "avro-serialize-action".

      Based on info from nicolaferraro, I suggest to edit the example:

      apiVersion: camel.apache.org/v1alpha1
      kind: KameletBinding
      metadata:
        name: avro-serialize-action-binding
      spec:
        source:
          ref:
            kind: Kamelet
            apiVersion: camel.apache.org/v1alpha1
            name: timer-source
          properties:
            message: '{"first":"Ada","last":"Lovelace"}'
        steps:
        - ref:
            kind: Kamelet
            apiVersion: camel.apache.org/v1alpha1
            name: json-deserialize-action
        - ref:
            kind: Kamelet
            apiVersion: camel.apache.org/v1alpha1
            name: avro-serialize-action
          properties:
            schema: "{\"type\": \"record\", \"namespace\": \"com.example\", \"name\": \"FullName\", \"fields\": [{\"name\": \"first\", \"type\": \"string\"},{\"name\": \"last\", \"type\": \"string\"}]}"
      ...
      

      Which runs correctly

            mflinn@redhat.com Melissa Flinn
            lfabriko@redhat.com Lucie Krejcirova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: