{
UUID chatRoomId = UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7");
int shard = shardingStrategy.selectShard(chatRoomId);
- chatRoomTemplate.send(TOPIC, null,"{\"id\":\"5c73531c-6fc4-426c-adcb-afc5c140a0f7\",\"shard\":" + shard + ",\"name\":\"FOO\"");
+ chatRoomTemplate.send(TOPIC, null,"{ \"id\": \"5c73531c-6fc4-426c-adcb-afc5c140a0f7\", \"shard\": " + shard + ", \"name\": \"FOO\" }");
messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"peter\", \"text\" : \"Hallo, ich heiße Peter!\" }");
messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"ute\", \"text\" : \"Ich bin Ute...\" }");
messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 2, \"user\" : \"peter\", \"text\" : \"Willst du mit mir gehen?\" }");
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;
JsonSerializer<ChatRoomTo> chatRoomSerializer()
{
JsonSerializer<ChatRoomTo> serializer = new JsonSerializer<>();
+ serializer.configure(
+ Map.of(JsonSerializer.ADD_TYPE_INFO_HEADERS, false),
+ false);
return serializer;
}
JsonDeserializer<ChatRoomTo> chatRoomDeserializer()
{
JsonDeserializer<ChatRoomTo> deserializer = new JsonDeserializer<>();
+ deserializer.configure(
+ Map.of(
+ JsonDeserializer.USE_TYPE_INFO_HEADERS, false,
+ JsonDeserializer.VALUE_DEFAULT_TYPE, ChatRoomTo.class,
+ JsonDeserializer.TRUSTED_PACKAGES, getClass().getPackageName()),
+ false );
return deserializer;
}
JsonSerializer<MessageTo> chatMessageSerializer()
{
JsonSerializer<MessageTo> serializer = new JsonSerializer<>();
+ serializer.configure(
+ Map.of(JsonSerializer.ADD_TYPE_INFO_HEADERS, false),
+ false);
return serializer;
}
JsonDeserializer<MessageTo> chatMessageDeserializer()
{
JsonDeserializer<MessageTo> deserializer = new JsonDeserializer<>();
+ deserializer.configure(
+ Map.of(
+ JsonDeserializer.USE_TYPE_INFO_HEADERS, false,
+ JsonDeserializer.VALUE_DEFAULT_TYPE, MessageTo.class,
+ JsonDeserializer.TRUSTED_PACKAGES, getClass().getPackageName()),
+ false );
return deserializer;
}