# Import topic to store with simple processing

**URL:** https://forum.confluent.io/t/import-topic-to-store-with-simple-processing/4098
**Category:** Kafka Streams
**Created:** [7 February 2022 11:16 UTC](https://forum.confluent.io/t/import-topic-to-store-with-simple-processing/4098 "2022-02-07T11:16:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jiinxx](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/jiinxx/32/1556_2.png) [@jiinxx](https://forum.confluent.io/u/jiinxx)
#### Post date: [7 February 2022 11:16 UTC](https://forum.confluent.io/t/import-topic-to-store-with-simple-processing/4098/1 "2022-02-07T11:16:36Z")

</div>

Hi,  
As part of an application that Im developing (Java, SpringBoot, SpringKafka, Spring Reactive) I need to import a couple of kafka-topics, join the data and expose it in a streaming fashion using WS. The topics contains the whole set of data at all times so the application doesnt need to keep any state as I see it - if the app goes down the data will be re-imported in total into the application.  
The data is in protobuf-format so It needs some parsing to be used in the application

Someone explained to me that this would be doable using Kafka Streams. I have experience of Kafka, but no experience of Kafka Streams

I first set out to solve the simplest case - importing one topic, and being able to query the data using a REST-interface.

Ive been scanning the Internet for examples but most of them are more advanced than the my simple case.  
Ive setup some kafka-configuration that seem to work and I have created a topic-importer-bean like this:

```auto
@Component
public class TopicProcessor {
    
        @Autowired
        void buildPipeline(StreamsBuilder streamsBuilder) {

            KeyValueBytesStoreSupplier storeSupplier = Stores.persistentKeyValueStore("mystore");

            Materialized<Object, Object, KeyValueStore<Bytes, byte[]>> mat2 =
                    Materialized.as(storeSupplier);

            streamsBuilder
                    .stream("my-topic", Consumed.with(Serdes.String(), Serdes.ByteArray()))
                    .mapValues(l -> parseProtobuf(l))
                    .filter((k, v) -> Objects.nonNull(v))
                    .map(((key, value) -> KeyValue.pair((Object) value.getId().getValue(), (Object) value)))
                    .toTable(mat2);

        }
}

```

However, the import fails with :

> Not authorized to access topics: [user-KSTREAM-TOTABLE-0000000004-repartition]

1. How do I solve this? Can I avoid it some how as I dont need the backing into topic?
2. As you can tell I cast the key and value to Object - this is because I cant it to work otherwise? How can store the \<key,value\> as \<String, MyObject\>?

Hope you dont think this a to simple question. Ive tried to solve it on my own but I simply cant get it to work.

Any input is welcome  
Best Regards

---

<div class="post-metadata">

### Author: ![rick](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rick/32/49_2.png) [@rick](https://forum.confluent.io/u/rick)
#### Post date: [7 February 2022 15:01 UTC](https://forum.confluent.io/t/import-topic-to-store-with-simple-processing/4098/2 "2022-02-07T15:01:53Z")

</div>

@jiinxx Your usage of the `map` function prior to calling `toTable`, _marks the stream for data re-partitioning_, and that’s why Kafka Streams is attempting to work with the underlying ‘repartition’ topic. See the streams reference docs here: [KStream (kafka 3.1.1 API)](https://kafka.apache.org/31/javadoc/org/apache/kafka/streams/kstream/KStream.html#toTable()). It seems that your application is not authorized to create/read/write to that topic, so you may need to verify the ACLs assigned to your application. Here is some documentation on ACLs for streams apps: [Kafka Streams Security | Confluent Documentation](https://docs.confluent.io/platform/current/streams/developer-guide/security.html#required-acl-setting-for-secure-ak-clusters)

For protobuf and data types, I cannot see the return type of the `parseProtobuf` function so I cannot see the type of the value objects after that invocation. Maybe this documentation on working with Serdes in Kafka Streams can help (There is a protobuf section): [Kafka Streams Data Types and Serialization | Confluent Documentation](https://docs.confluent.io/platform/current/streams/developer-guide/datatypes.html)

Hope this helps some
