Giter Site home page Giter Site logo

Comments (4)

sabbyanandan avatar sabbyanandan commented on August 28, 2024

Depends on spring-cloud/spring-cloud-stream#519

from spring-cloud-stream-binder-kafka.

mbogoevici avatar mbogoevici commented on August 28, 2024

Duplicated by #144

from spring-cloud-stream-binder-kafka.

codependent avatar codependent commented on August 28, 2024

@mbogoevici It's great to have KStreams available directly in Spring Cloud Streams. I only miss one thing:

With Spring Kafka I wanted to use interative queries so I configured KStreams like this to generate a KTable:

KStream<Integer, JsonNode> stream = kStreamBuilder.stream(integerSerde, jsonSerde, STREAMING_TOPIC1);

stream.map( (key, value) -> {
    return new KeyValue<>(value.get("productId").asInt(), value.get("quantity").asInt());
}).groupByKey().reduce( (v1, v2) -> v1 + v2, "ProductsStock");

Then in my business service I injected KStreamBuilderFactoryBean to have access to KafkaStreams and thus be able to implement the query against the previously defined store:

@Autowired
private KStreamBuilderFactoryBean kStreamBuilderFactoryBean;

@Override
public Integer getProductStock(Integer id) {
        KafkaStreams streams = kStreamBuilderFactoryBean.getKafkaStreams();
        ReadOnlyKeyValueStore<Integer, Integer> keyValueStore =
        streams.store("ProductsStock", QueryableStoreTypes.keyValueStore());
        return keyValueStore.get(id);
}

Do we have to do the same to use the interactive queries when using Spring Cloud Streams?

from spring-cloud-stream-binder-kafka.

artembilan avatar artembilan commented on August 28, 2024

@codependent ,

Yes, according to the code in the PR #159 from @sobychacko , we have:

@Bean(name = KafkaStreamsDefaultConfiguration.DEFAULT_KSTREAM_BUILDER_BEAN_NAME)
public KStreamBuilderFactoryBean defaultKStreamBuilder(

So, that is really feasible what we have discussed with you in the spring-projects/spring-kafka#365

Why do you think that might be something different?

Thanks for your feedback though!

from spring-cloud-stream-binder-kafka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.