-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bare minimum Kafka producer. Downgrade Java version, since 23 doe…
…s not have security manager which is needed by Kafka. More details here - quarkusio/quarkus#39634.
- Loading branch information
1 parent
c77ef5d
commit 2c3a8db
Showing
8 changed files
with
132 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ava/com/ikea/assignment/product_information_system/model/ProductPriceUpdateEventData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.ikea.assignment.product_information_system.model; | ||
|
||
public class ProductPriceUpdateEventData { | ||
private String country; | ||
private String oldPrice; | ||
private String newPrice; | ||
private String sku; | ||
private String timestamp; | ||
|
||
public ProductPriceUpdateEventData(String country, String oldPrice, String newPrice, String sku, String timestamp) { | ||
this.country = country; | ||
this.oldPrice = oldPrice; | ||
this.newPrice = newPrice; | ||
this.sku = sku; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public String getCountry() { | ||
return country; | ||
} | ||
|
||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
|
||
public String getOldPrice() { | ||
return oldPrice; | ||
} | ||
|
||
public void setOldPrice(String oldPrice) { | ||
this.oldPrice = oldPrice; | ||
} | ||
|
||
public String getNewPrice() { | ||
return newPrice; | ||
} | ||
|
||
public void setNewPrice(String newPrice) { | ||
this.newPrice = newPrice; | ||
} | ||
|
||
public String getSku() { | ||
return sku; | ||
} | ||
|
||
public void setSku(String sku) { | ||
this.sku = sku; | ||
} | ||
|
||
public String getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public void setTimestamp(String timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../com/ikea/assignment/product_information_system/producers/ProductPriceUpdateProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.ikea.assignment.product_information_system.producers; | ||
|
||
import com.ikea.assignment.product_information_system.model.Product; | ||
import com.ikea.assignment.product_information_system.model.ProductPriceUpdateEventData; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
@Service | ||
public class ProductPriceUpdateProducer { | ||
@Autowired | ||
private KafkaTemplate<String, ProductPriceUpdateEventData> kafkaTemplate; | ||
|
||
@Value("${kafka.price.update.topic.suffix}") | ||
private String priceUpdateTopicSuffix; | ||
|
||
public void send(Product oldProduct, Product newProduct) { | ||
String topicName = newProduct.getCountry().toString() + "-" + priceUpdateTopicSuffix; | ||
String date = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date()); | ||
ProductPriceUpdateEventData productPriceUpdateEventData = new ProductPriceUpdateEventData(newProduct.getCountry().toString(), oldProduct.getPrice().toString(), newProduct.getPrice().toString(), newProduct.getSku(), date); | ||
kafkaTemplate.send(topicName, newProduct.getSku(), productPriceUpdateEventData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
spring.application.name=product-information-system | ||
|
||
spring.cassandra.keyspace-name=main | ||
spring.cassandra.username=<username> | ||
spring.cassandra.password=<password> | ||
spring.cassandra.schema-action=create_if_not_exists | ||
|
||
datastax.astra.secure-connect-bundle=src/main/resources/secure-connect.zip | ||
|
||
astra.db.id=<db-id> | ||
astra.db.region=us-east1 | ||
astra.db.application.token=<token> | ||
astra.db.keyspace=main | ||
|
||
spring.kafka.bootstrap-servers=product-information-system-demo-product-information-system-demo.c.aivencloud.com:11627 | ||
spring.kafka.properties.security.protocol=SASL_SSL | ||
spring.kafka.properties.sasl.mechanism=SCRAM-SHA-256 | ||
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username=<username> password=<password>; | ||
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer | ||
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringSerializer | ||
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer | ||
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonSerializer | ||
spring.kafka.consumer.group-id=product-price-update-group | ||
spring.kafka.ssl.endpoint.identification.algorithm= | ||
spring.kafka.ssl.truststore.type=jks | ||
spring.kafka.ssl.truststore.password=<password> | ||
spring.kafka.properties.ssl.endpoint.identification.algorithm= | ||
spring.kafka.properties.ssl.truststore.type=jks | ||
spring.kafka.properties.ssl.truststore.location=src/main/resources/client.truststore.jks | ||
spring.kafka.properties.ssl.truststore.password=<password> | ||
|
||
kafka.price.update.topic.suffix=product-price-updates | ||
kafka.country.update.topic.suffix=product-country-updates | ||
kafka.discount-percentage.update.topic.suffix=product-discount-updates |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.