Browse Source

Change configuration to use hosted kafka

pull/2110/head
Philipp Theyssen 1 year ago
parent
commit
bb2ca8b9ff
13 changed files with 167 additions and 128 deletions
  1. +1
    -1
      src/BuildingBlocks/EventBus/EventBusKafka/KafkaConsumerBackgroundService.cs
  2. +1
    -16
      src/Services/Basket/Basket.API/appsettings.Development.json
  3. +23
    -5
      src/Services/Basket/Basket.API/appsettings.json
  4. +0
    -13
      src/Services/Catalog/Catalog.API/appsettings.Development.json
  5. +25
    -4
      src/Services/Catalog/Catalog.API/appsettings.json
  6. +1
    -1
      src/Services/Ordering/Ordering.API/Application/Commands/SetPaidOrderStatusCommandHandler.cs
  7. +30
    -9
      src/Services/Ordering/Ordering.API/appsettings.json
  8. +0
    -12
      src/Services/Ordering/Ordering.BackgroundTasks/appsettings.Development.json
  9. +26
    -5
      src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json
  10. +0
    -12
      src/Services/Payment/Payment.API/appsettings.Development.json
  11. +30
    -9
      src/Services/Payment/Payment.API/appsettings.json
  12. +22
    -22
      src/docker-compose.override.yml
  13. +8
    -19
      src/docker-compose.yml

+ 1
- 1
src/BuildingBlocks/EventBus/EventBusKafka/KafkaConsumerBackgroundService.cs View File

@ -48,7 +48,7 @@ public class KafkaConsumerBackgroundService : BackgroundService
if (!_subsManager.HasSubscriptionsForEvent(eventName)) if (!_subsManager.HasSubscriptionsForEvent(eventName))
{ {
_logger.LogWarning("No subscription for Kafka event: {EventName}", eventName);
// _logger.LogWarning("No subscription for Kafka event: {EventName}", eventName);
continue; continue;
} }


+ 1
- 16
src/Services/Basket/Basket.API/appsettings.Development.json View File

@ -13,20 +13,5 @@
"IdentityUrl": "http://localhost:5105", "IdentityUrl": "http://localhost:5105",
"ConnectionString": "127.0.0.1", "ConnectionString": "127.0.0.1",
"AzureServiceBusEnabled": false, "AzureServiceBusEnabled": false,
"EventBusConnection": "localhost",
"KafkaEnabled": true,
"Kafka": {
"AdminSettings": {
"BootstrapServers": "broker:9092"
},
"ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
},
"ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "basket-group-id",
"AllowAutoCreateTopics": true
}
}
"EventBusConnection": "localhost"
} }

+ 23
- 5
src/Services/Basket/Basket.API/appsettings.json View File

@ -30,16 +30,34 @@
"KafkaEnabled": true, "KafkaEnabled": true,
"Kafka": { "Kafka": {
"AdminSettings": { "AdminSettings": {
"BootstrapServers": "broker:9092"
"GroupId": "basket-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
}, },
"ProducerSettings": { "ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
"GroupId": "basket-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
}, },
"ConsumerSettings": { "ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "basket-group-id", "GroupId": "basket-group-id",
"AllowAutoCreateTopics": true
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"AutoOffsetReset": "Earliest",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
} }
} }
} }

+ 0
- 13
src/Services/Catalog/Catalog.API/appsettings.Development.json View File

@ -10,18 +10,5 @@
"System": "Warning" "System": "Warning"
} }
} }
},
"EventBusConnection": "localhost",
"KafkaEnabled": true,
"Kafka": {
"ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
},
"ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "catalog-group-id",
"AllowAutoCreateTopics": true
}
} }
} }

+ 25
- 4
src/Services/Catalog/Catalog.API/appsettings.json View File

@ -27,14 +27,35 @@
}, },
"KafkaEnabled": true, "KafkaEnabled": true,
"Kafka": { "Kafka": {
"AdminSettings": {
"GroupId": "catalog-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
},
"ProducerSettings": { "ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
"GroupId": "catalog-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
}, },
"ConsumerSettings": { "ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "catalog-group-id", "GroupId": "catalog-group-id",
"AllowAutoCreateTopics": true
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"AutoOffsetReset": "Earliest",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
} }
} }
} }


+ 1
- 1
src/Services/Ordering/Ordering.API/Application/Commands/SetPaidOrderStatusCommandHandler.cs View File

@ -19,7 +19,7 @@ public class SetPaidOrderStatusCommandHandler : IRequestHandler<SetPaidOrderStat
public async Task<bool> Handle(SetPaidOrderStatusCommand command, CancellationToken cancellationToken) public async Task<bool> Handle(SetPaidOrderStatusCommand command, CancellationToken cancellationToken)
{ {
// Simulate a work time for validating the payment // Simulate a work time for validating the payment
await Task.Delay(10000, cancellationToken);
await Task.Delay(2000, cancellationToken);
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber); var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
if (orderToUpdate == null) if (orderToUpdate == null)


+ 30
- 9
src/Services/Ordering/Ordering.API/appsettings.json View File

@ -25,15 +25,36 @@
"EventBusConnection": "localhost", "EventBusConnection": "localhost",
"KafkaEnabled": true, "KafkaEnabled": true,
"Kafka": { "Kafka": {
"ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
},
"ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "ordering-group-id",
"AllowAutoCreateTopics": true
}
"AdminSettings": {
"GroupId": "ordering-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
},
"ProducerSettings": {
"GroupId": "ordering-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
},
"ConsumerSettings": {
"GroupId": "ordering-group-id",
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"AutoOffsetReset": "Earliest",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
}
}, },
"UseVault": false, "UseVault": false,
"Vault": { "Vault": {


+ 0
- 12
src/Services/Ordering/Ordering.BackgroundTasks/appsettings.Development.json View File

@ -5,17 +5,5 @@
"System": "Information", "System": "Information",
"Microsoft": "Information" "Microsoft": "Information"
} }
},
"KafkaEnabled": true,
"Kafka": {
"ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
},
"ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "ordering-background-group-id",
"AllowAutoCreateTopics": true
}
} }
} }

+ 26
- 5
src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json View File

@ -25,14 +25,35 @@
"EventBusPassword": "", "EventBusPassword": "",
"KafkaEnabled": true, "KafkaEnabled": true,
"Kafka": { "Kafka": {
"AdminSettings": {
"GroupId": "ordering-background-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "MMn/CFO53yA631L8/EW1iXbmVWzN/3DZgJgWfQDBTreEgDhp4ica8SyaDqE9iP7r"
},
"ProducerSettings": { "ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
"GroupId": "ordering-background-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "MMn/CFO53yA631L8/EW1iXbmVWzN/3DZgJgWfQDBTreEgDhp4ica8SyaDqE9iP7r"
}, },
"ConsumerSettings": { "ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "ordering-background-group-id", "GroupId": "ordering-background-group-id",
"AllowAutoCreateTopics": true
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"AutoOffsetReset": "Earliest",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "MMn/CFO53yA631L8/EW1iXbmVWzN/3DZgJgWfQDBTreEgDhp4ica8SyaDqE9iP7r"
} }
} }
}
}

+ 0
- 12
src/Services/Payment/Payment.API/appsettings.Development.json View File

@ -6,17 +6,5 @@
"System": "Information", "System": "Information",
"Microsoft": "Information" "Microsoft": "Information"
} }
},
"KafkaEnabled": true,
"Kafka": {
"ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
},
"ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "payment-group-id",
"AllowAutoCreateTopics": true
}
} }
} }

+ 30
- 9
src/Services/Payment/Payment.API/appsettings.json View File

@ -20,14 +20,35 @@
"EventBusRetryCount": 5, "EventBusRetryCount": 5,
"KafkaEnabled": true, "KafkaEnabled": true,
"Kafka": { "Kafka": {
"ProducerSettings": {
"BootstrapServers": "broker:9092",
"AllowAutoCreateTopics": true
},
"ConsumerSettings": {
"BootstrapServers": "broker:9092",
"GroupId": "payment-group-id",
"AllowAutoCreateTopics": true
}
"AdminSettings": {
"GroupId": "payment-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
},
"ProducerSettings": {
"GroupId": "payment-group-id",
"AllowAutoCreateTopics": true,
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
},
"ConsumerSettings": {
"GroupId": "payment-group-id",
"BootstrapServers": "pkc-xmzwx.europe-central2.gcp.confluent.cloud:9092",
"AutoOffsetReset": "Earliest",
"SslEndpointIdentificationAlgorithm": "Https",
"SecurityProtocol": "SaslSsl",
"SaslMechanism": "Plain",
"SaslUsername": "username",
"SaslPassword": "password"
}
} }
} }

+ 22
- 22
src/docker-compose.override.yml View File

@ -34,30 +34,30 @@ services:
volumes: volumes:
- eshop-basketdata:/data - eshop-basketdata:/data
rabbitmq:
ports:
- "15672:15672"
- "5672:5672"
# rabbitmq:
# ports:
# - "15672:15672"
# - "5672:5672"
zookeeper:
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
# zookeeper:
# environment:
# ZOOKEEPER_CLIENT_PORT: 2181
# ZOOKEEPER_TICK_TIME: 2000
broker:
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
ports:
# To learn about configuring Kafka for access across networks see
# https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
- "9092:9092"
- "29092:29092"
# broker:
# environment:
# KAFKA_BROKER_ID: 1
# KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
# KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
# KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_HOST://localhost:29092
# KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
# KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
# KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
# ports:
# # To learn about configuring Kafka for access across networks see
# # https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/
# - "9092:9092"
# - "29092:29092"
identity-api: identity-api:
environment: environment:


+ 8
- 19
src/docker-compose.yml View File

@ -14,16 +14,16 @@ services:
basketdata: basketdata:
image: redis:alpine image: redis:alpine
rabbitmq:
image: rabbitmq:3-management-alpine
# rabbitmq:
# image: rabbitmq:3-management-alpine
zookeeper:
image: confluentinc/cp-zookeeper:7.3.0
# zookeeper:
# image: confluentinc/cp-zookeeper:7.3.0
broker:
image: confluentinc/cp-kafka:7.3.0
depends_on:
- zookeeper
# broker:
# image: confluentinc/cp-kafka:7.3.0
# depends_on:
# - zookeeper
identity-api: identity-api:
image: ${REGISTRY:-eshop}/identity.api:${PLATFORM:-linux}-${TAG:-latest} image: ${REGISTRY:-eshop}/identity.api:${PLATFORM:-linux}-${TAG:-latest}
@ -41,8 +41,6 @@ services:
depends_on: depends_on:
- basketdata - basketdata
- identity-api - identity-api
- rabbitmq
- broker
catalog-api: catalog-api:
image: ${REGISTRY:-eshop}/catalog.api:${PLATFORM:-linux}-${TAG:-latest} image: ${REGISTRY:-eshop}/catalog.api:${PLATFORM:-linux}-${TAG:-latest}
@ -51,8 +49,6 @@ services:
dockerfile: Services/Catalog/Catalog.API/Dockerfile dockerfile: Services/Catalog/Catalog.API/Dockerfile
depends_on: depends_on:
- sqldata - sqldata
- rabbitmq
- broker
ordering-api: ordering-api:
image: ${REGISTRY:-eshop}/ordering.api:${PLATFORM:-linux}-${TAG:-latest} image: ${REGISTRY:-eshop}/ordering.api:${PLATFORM:-linux}-${TAG:-latest}
@ -61,8 +57,6 @@ services:
dockerfile: Services/Ordering/Ordering.API/Dockerfile dockerfile: Services/Ordering/Ordering.API/Dockerfile
depends_on: depends_on:
- sqldata - sqldata
- rabbitmq
- broker
ordering-backgroundtasks: ordering-backgroundtasks:
image: ${REGISTRY:-eshop}/ordering.backgroundtasks:${PLATFORM:-linux}-${TAG:-latest} image: ${REGISTRY:-eshop}/ordering.backgroundtasks:${PLATFORM:-linux}-${TAG:-latest}
@ -71,17 +65,12 @@ services:
dockerfile: Services/Ordering/Ordering.BackgroundTasks/Dockerfile dockerfile: Services/Ordering/Ordering.BackgroundTasks/Dockerfile
depends_on: depends_on:
- sqldata - sqldata
- rabbitmq
- broker
payment-api: payment-api:
image: ${REGISTRY:-eshop}/payment.api:${PLATFORM:-linux}-${TAG:-latest} image: ${REGISTRY:-eshop}/payment.api:${PLATFORM:-linux}-${TAG:-latest}
build: build:
context: . context: .
dockerfile: Services/Payment/Payment.API/Dockerfile dockerfile: Services/Payment/Payment.API/Dockerfile
depends_on:
- rabbitmq
- broker
# webhooks-api: # webhooks-api:
# image: ${REGISTRY:-eshop}/webhooks.api:${PLATFORM:-linux}-${TAG:-latest} # image: ${REGISTRY:-eshop}/webhooks.api:${PLATFORM:-linux}-${TAG:-latest}


Loading…
Cancel
Save