Need help connecting to existing Kafka #1136
-
Hello, I'm trying to configure microcks to interact with existing kafka. to raise containers with microcks I use the command I removed the zookiper and kafka raising services from the docker-compose-async-addon.yml file this is what the file looks like version: '2'
services:
app:
depends_on:
- mongo
- keycloak
- postman
image: quay.io/microcks/microcks:1.9.0
container_name: microcks
volumes:
- "./config:/deployments/config"
ports:
- "8080:8080"
- "9090:9090"
environment:
- SPRING_PROFILES_ACTIVE=prod
- SPRING_DATA_MONGODB_URI=mongodb://mongo:27017
- SPRING_DATA_MONGODB_DATABASE=microcks
- POSTMAN_RUNNER_URL=http://postman:3000
- TEST_CALLBACK_URL=http://microcks:8080
- SERVICES_UPDATE_INTERVAL=0 0 0/2 * * *
- KEYCLOAK_URL=http://keycloak:8080
- KEYCLOAK_PUBLIC_URL=http://localhost:18080
- JAVA_OPTIONS=-Dspring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:18080/realms/microcks -Dspring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://keycloak:8080/realms/microcks/protocol/openid-connect/certs
- ASYNC_MINION_URL=http://microcks-async-minion:8081
- KAFKA_BOOTSTRAP_SERVER=host.docker.internal:9092
async-minion:
depends_on:
- app
ports:
- "8081:8081"
image: quay.io/microcks/microcks-async-minion:1.9.0
container_name: microcks-async-minion
restart: on-failure
volumes:
- "./config:/deployments/config"
environment:
- QUARKUS_PROFILE=docker-compose Kafka is raised in another container and accessed via url:port localhost:9092 additionally I changed the file install/docker-compose/config/application.properties # Access to Kafka broker.
%docker-compose.kafka.bootstrap.servers=host.docker.internal:9092
# Do not save any consumer-offset on the broker as there's a re-sync on each minion startup.
%docker-compose.mp.messaging.incoming.microcks-services-updates.enable.auto.commit=false
%docker-compose.mp.messaging.incoming.microcks-services-updates.bootstrap.servers=host.docker.internal:9092
# Explicitly telling the minion the protocols we want to support
%docker-compose.minion.supported-bindings=KAFKA,WS additionally I changed the file features.feature.async-api.default-binding=KAFKA
features.feature.async-api.endpoint-KAFKA=localhost:9092 and it doesn't work, it gives me an error
at the same time, it is logged as sending to a non-existent topic UsersignedupAPIv2-0.1.2-TestTopicBroh I use the openapi specification asyncapi: '2.0.0'
id: 'urn:io.microcks.example.user-signedup-v2'
info:
title: User signed-up API v2
version: 0.1.2
description: Sample AsyncAPI for user signedup events, version 2
defaultContentType: application/json
channels:
TestTopicBroh:
description: The topic on which user signed up events may be consumed
subscribe:
summary: Receive information about user signed up
operationId: userSignedUpSubscriptionV2
message:
description: An event describing that a user has just signed up.
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
type: object
additionalProperties: false
properties:
id:
type: string
sendAt:
type: string
fullName:
type: string
email:
type: string
format: email
age:
type: integer
minimum: 18
examples:
- laurent:
summary: Example for Laurent user
headers: |-
{"my-app-header": 23}
payload: |-
{"id": "{{randomString(32)}}", "sendAt": "{{now()}}", "fullName": "Laurent Broudoux", "email": "laurent@microcks.io", "age": 41}
- john:
summary: Example for John Doe user
headers:
my-app-header: 24
payload:
id: '{{randomString(32)}}'
sendAt: '{{now()}}'
fullName: John Doe
email: john@microcks.io
age: 36
components:
messageTraits:
commonHeaders:
headers:
type: object
properties:
my-app-header:
type: integer
minimum: 0
maximum: 100` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Sorry for the late reply... I just got some time to have a look at it. Will keep you updated ASAP. |
Beta Was this translation helpful? Give feedback.
-
So... The name of the topic Now the problem with this setup is certainly due to how the Kafka listener is advertised by the Kafka bootstrap server. From within the Microcks containers, you're using So depending on your Kafka implementation, you may be able to configure another listener (on another port) that advertises node server differently and in a way that it can be reached from within the docker network. That's why - most of the time - it's easier to have either Kafka running in the docker network and using different listeners and aliases (that's typically what we're doing) OR to have an external Kafka on another machine that both host and docker networks can resolve the same way. |
Beta Was this translation helpful? Give feedback.
So...
The name of the topic
UsersignedupAPIv2-0.1.2-TestTopicBroh
is expected as it is managed by Microcks for its mocks to avoid collisions with other stuff. The fact that you cannot see it clearly means that Microcks is not able to connect to the Kafka broker.Now the problem with this setup is certainly due to how the Kafka listener is advertised by the Kafka bootstrap server. From within the Microcks containers, you're using
host.docker.internal:9092
that is correct and correspond to the bootstrap server. However, the defautl configuration of bootstrap is to advertise the connection to a Kafka node server that has the same host that the one it is running on - probablylocalhost:9092
. …