ivangfr/spring-cloud-stream-kafka-elasticsearch

Spring Cloud Stream Multiple Binding

xadimousalih opened this issue · 5 comments

Hi Ivan,

At first thanks for your sample it's working well! I try to make some change in the code.
What's wrong in my yml file i am trying to make multiple binding in the producer-api?

Can u help me

`spring:
cloud:
schema-registry-client:
endpoint: http://${SCHEMA_REGISTRY_HOST:localhost}:${SCHEMA_REGISTRY_PORT:8081}
schema:
avro:
schema-locations:
- classpath:avro/news-event.avsc
- classpath:avro/bayite-event.avsc
- classpath:avro/khassida-event.avsc
stream:
kafka:
binder:
brokers: ${KAFKA_HOST:localhost}:${KAFKA_PORT:29092}
auto-add-partitions: true
source: news, bayite, khassida
bindings:
news-out-0:
destination: com.mycompany.newspipeline.producer.news
content-type: application/+avro
producer:
partition-key-expression: headers['partitionKey']
partition-count: 2
bayite-out-0:
destination: com.mycompany.bayitepipeline.producer.bayite
content-type: application/
+avro
producer:
partition-key-expression: headers['partitionKey']
partition-count: 3
khassida-out-0:
destination: com.mycompany.khassidapipeline.producer.khassida
content-type: application/*+avro
producer:
partition-key-expression: headers['partitionKey']
partition-count: 4
sleuth:
sampler:
probability: 1.0

management:
endpoints:
web:
exposure.include: beans, env, health, info, metrics, mappings
endpoint:
health:
show-details: always

eureka:
client:
serviceUrl:
defaultZone: http://${EUREKA_HOST:localhost}:${EUREKA_PORT:8761}/eureka
instance:
preferIpAddress: true

springdoc:
show-actuator: true
swagger-ui:
groups-order: DESC`

Hi @xadimousalih ,

Just seeing the application.yml file is very difficult to say what is the problem. Besides, the file lost all indentation. Is the project you are developing private? Could you share it so that I can try it locally?

Hi @ivangfr

At first thank for your availability!

I create a new repo for my project which i clone yours

https://github.com/xadimousalih/mourid-apis.git

Thanks in advance!

@xadimousalih here are the changes I made to make, at least, producer-api to start

diff --git a/producer-api/src/main/resources/application.yml b/producer-api/src/main/resources/application.yml
index aa3c6d9..3d04229 100644
--- a/producer-api/src/main/resources/application.yml
+++ b/producer-api/src/main/resources/application.yml
@@ -5,14 +5,15 @@ spring:
     schema:
       avro:
         schema-locations:
-          - classpath:avro/news-event.avsc,avro/bayite-event.avsc
+          - classpath:avro/news-event.avsc
+          - classpath:avro/bayite-event.avsc
           - classpath:avro/khassida-event.avsc
     stream:
       kafka:
         binder:
           brokers: ${KAFKA_HOST:localhost}:${KAFKA_PORT:29092}
           auto-add-partitions: true
-      source: news, bayite, khassida
+      source: news;bayite;khassida
       bindings:
         news-out-0:
           destination: com.mycompany.newspipeline.producer.news
diff --git a/producer-api/src/main/resources/avro/khassida-event.avsc b/producer-api/src/main/resources/avro/khassida-event.avsc
index e5555a9..4ceeffe 100644
--- a/producer-api/src/main/resources/avro/khassida-event.avsc
+++ b/producer-api/src/main/resources/avro/khassida-event.avsc
@@ -1,7 +1,7 @@
 {
-       "namespace": "com.mycompany.commonsbayite.avro",
+       "namespace": "com.mycompany.commonskhassida.avro",
        "type": "record",
-       "name": "BayiteEvent",
+       "name": "KhassidaEvent",
        "fields": [
                {"name": "id", "type": "string"},
                {"name": "titre", "type": "string"},
@@ -12,6 +12,6 @@
                {"name": "nombreBayite", "type": ["null", "string"], "default": null},
                {"name": "nombreBaate", "type": ["null", "string"], "default": null},
                {"name": "nombreAraf", "type": ["null", "string"], "default": null},
-               {"name": "category", "type": ["null", "string"], "default": null}
+               {"name": "categorie", "type": ["null", "string"], "default": null}
        ]
 }
\ No newline at end of file

Hi @xadimousalih did the suggestions help? Can I close this issue?

Hello Ivan,

Yeah it work well now! You can close.

I'll add spring security micro service with keyclock for authentication and authorization.

Thank you