Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic structure for kafka consumers
* All TODOs are prefixed with 'TODO: kafka source' Signed-off-by: Yannic Klem <yannic.klem@bosch.io>
- Loading branch information
Showing
11 changed files
with
433 additions
and
23 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
44 changes: 44 additions & 0 deletions
44
...ce/src/main/java/org/eclipse/ditto/connectivity/service/messaging/kafka/ConsumerData.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,44 @@ | ||
/* | ||
* Copyright (c) 2021 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.connectivity.service.messaging.kafka; | ||
|
||
import org.eclipse.ditto.connectivity.model.Source; | ||
|
||
/** | ||
* This is class holds the data to identify a single address of a source of a kafka connection. | ||
*/ | ||
final class ConsumerData { | ||
|
||
private final Source source; | ||
private final String address; | ||
private final String addressWithIndex; | ||
|
||
ConsumerData(final Source source, final String address, final String addressWithIndex) { | ||
this.source = source; | ||
this.address = address; | ||
this.addressWithIndex = addressWithIndex; | ||
} | ||
|
||
Source getSource() { | ||
return source; | ||
} | ||
|
||
String getAddress() { | ||
return address; | ||
} | ||
|
||
String getActorNamePrefix() { | ||
return KafkaConsumerActor.ACTOR_NAME_PREFIX + source.getIndex() + "-" + addressWithIndex; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...ava/org/eclipse/ditto/connectivity/service/messaging/kafka/ConsumerPropertiesFactory.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,45 @@ | ||
/* | ||
* Copyright (c) 2021 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.connectivity.service.messaging.kafka; | ||
|
||
import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull; | ||
|
||
import java.util.Properties; | ||
|
||
import org.apache.kafka.common.serialization.Serdes; | ||
import org.apache.kafka.streams.StreamsConfig; | ||
import org.eclipse.ditto.connectivity.model.Connection; | ||
|
||
final class ConsumerPropertiesFactory { | ||
|
||
private final Connection connection; | ||
|
||
private ConsumerPropertiesFactory(final Connection connection) { | ||
this.connection = checkNotNull(connection, "connection"); | ||
} | ||
|
||
static ConsumerPropertiesFactory getInstance(final Connection connection) { | ||
return new ConsumerPropertiesFactory(connection); | ||
} | ||
|
||
Properties getConsumerProperties() { | ||
// TODO: kafka source - Adjust configuration according to kafka documentation | ||
Properties properties = new Properties(); | ||
properties.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, connection.getUri()); | ||
properties.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, connection.getId().toString()); | ||
properties.setProperty(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); | ||
properties.setProperty(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); | ||
return properties; | ||
} | ||
|
||
} |
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
Oops, something went wrong.