Is there a way to use guids? #32
jhoward321
started this conversation in
General
Replies: 2 comments 1 reply
-
Hi @jhoward321, EntityCreationMetadata metadata = new()
{
KafkaTopic = "MyGuids",
ValueFormat = SerializationFormats.Json,
Partitions = 1,
Replicas = 1,
ShouldPluralizeEntityName = true,
IncludeReadOnlyProperties = true
};
var httpResponseMessage = await restApiProvider.CreateStreamAsync<LinkCreated>(metadata, ifNotExists: true)
.ConfigureAwait(false);
httpResponseMessage = await restApiProvider.InsertIntoAsync(new LinkCreated() { AggregateRootId = Guid.NewGuid(), Name = "test" })
.ConfigureAwait(false);
using var subscription = context.CreateQueryStream<LinkCreated>()
.Subscribe(onNext: link =>
{
Console.WriteLine($"{nameof(LinkCreated)}: {link.AggregateRootId}");
Console.WriteLine();
}, onError: error => { Console.WriteLine($"Exception: {error.Message}"); }, onCompleted: () => Console.WriteLine("Completed")); public record LinkCreated : BaseDomainEvent<Link>
{
public LinkCreated() { }
public string Name { get; set; }
[Key]
public Guid AggregateRootId { get; set; }
} Would correspond with the bellow CREATE STREAM IF NOT EXISTS LINKCREATEDS (
NAME STRING,
AGGREGATEROOTID STRING KEY
) WITH (KAFKA_TOPIC='MyGuids', KEY_FORMAT='KAFKA', PARTITIONS='1', REPLICAS='1', VALUE_FORMAT='JSON');
INSERT INTO LinkCreateds (Name, AggregateRootId) VALUES ('test', '5ef6534b-b845-456e-bc29-2cdd55cd89ae'); Regards Tomas |
Beta Was this translation helpful? Give feedback.
0 replies
-
I published a preview release with the above mentioned changes. Could you try it out @jhoward321 and let me know if everything works as expected, please?
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a PoC for my company where we are implementing event sourcing using kafka/ksql. One of our requirements is guid primary key values due to some legacy behaviors.
I've been struggling configuring the client to configure the stream to allow a guid column. I know it's not a supported column type, but can I map it to a varchar somehow?
Here's what I'm trying to model into a stream. When I try to create the stream I get the following error:
Failed to prepare statement: Cannot resolve unknown type: GUID
How can I map this to a varchar?
Beta Was this translation helpful? Give feedback.
All reactions