import de.juplo.kafka.chat.backend.ChatBackendProperties;
import de.juplo.kafka.chat.backend.domain.ChatHome;
-import de.juplo.kafka.chat.backend.domain.Message;
import de.juplo.kafka.chat.backend.domain.ShardingStrategy;
import de.juplo.kafka.chat.backend.persistence.KafkaLikeShardingStrategy;
import org.apache.kafka.clients.consumer.Consumer;
@Bean
Producer<Integer, ChatRoomTo> chatRoomChannelProducer(
Properties defaultProducerProperties,
+ ChatBackendProperties chatBackendProperties,
IntegerSerializer integerSerializer,
JsonSerializer<ChatRoomTo> chatRoomSerializer)
{
+ Map<String, Object> properties = new HashMap<>();
+ defaultProducerProperties.forEach((key, value) -> properties.put(key.toString(), value));
+ properties.put(
+ ProducerConfig.CLIENT_ID_CONFIG,
+ chatBackendProperties.getKafka().getClientIdPrefix() + "_CHATROOM_CHANNEL_PRODUCER");
return new KafkaProducer<>(
- defaultProducerProperties,
+ properties,
integerSerializer,
chatRoomSerializer);
}
@Bean
Consumer<Integer, ChatRoomTo> chatRoomChannelConsumer(
Properties defaultConsumerProperties,
+ ChatBackendProperties chatBackendProperties,
IntegerDeserializer integerDeserializer,
JsonDeserializer<ChatRoomTo> chatRoomDeserializer)
{
Map<String, Object> properties = new HashMap<>();
defaultConsumerProperties.forEach((key, value) -> properties.put(key.toString(), value));
+ properties.put(
+ ConsumerConfig.CLIENT_ID_CONFIG,
+ chatBackendProperties.getKafka().getClientIdPrefix() + "_MESSAGE_CHANNEL_CONSUMER");
properties.put(
ConsumerConfig.GROUP_ID_CONFIG,
"chat_room_channel");
@Bean
Producer<String, MessageTo> chatMessageChannelProducer(
Properties defaultProducerProperties,
+ ChatBackendProperties chatBackendProperties,
StringSerializer stringSerializer,
JsonSerializer<MessageTo> messageSerializer)
{
+ Map<String, Object> properties = new HashMap<>();
+ defaultProducerProperties.forEach((key, value) -> properties.put(key.toString(), value));
+ properties.put(
+ ProducerConfig.CLIENT_ID_CONFIG,
+ chatBackendProperties.getKafka().getClientIdPrefix() + "_MESSAGE_CHANNEL_PRODUCER");
return new KafkaProducer<>(
- defaultProducerProperties,
+ properties,
stringSerializer,
messageSerializer);
}
@Bean
Consumer<String, MessageTo> chatMessageChannelConsumer(
Properties defaultConsumerProperties,
+ ChatBackendProperties chatBackendProperties,
StringDeserializer stringDeserializer,
JsonDeserializer<MessageTo> messageDeserializer)
{
Map<String, Object> properties = new HashMap<>();
defaultConsumerProperties.forEach((key, value) -> properties.put(key.toString(), value));
+ properties.put(
+ ConsumerConfig.CLIENT_ID_CONFIG,
+ chatBackendProperties.getKafka().getClientIdPrefix() + "_MESSAGE_CHANNEL_CONSUMER");
properties.put(
ConsumerConfig.GROUP_ID_CONFIG,
"chat_message_channel");
Properties defaultProducerProperties(ChatBackendProperties chatBackendProperties)
{
Properties properties = new Properties();
- properties.setProperty(
- ProducerConfig.CLIENT_ID_CONFIG,
- chatBackendProperties.getKafka().getClientId());
properties.setProperty(
ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
chatBackendProperties.getKafka().getBootstrapServers());
chatBackendProperties.getKafka().getBootstrapServers());
properties.setProperty(
ConsumerConfig.CLIENT_ID_CONFIG,
- chatBackendProperties.getKafka().getClientId());
+ chatBackendProperties.getKafka().getClientIdPrefix());
properties.setProperty(
ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG,
"false");