How to check if record exists in write model?

When importing objects from a 3rd party system, how do I make it idempotent in case I get the same object twice? Do I send a command to myself to check if the object exists, and if it does, I do nothing, but if it doesn’t exist yet, I emit an ObjectCreated event? How do I check if it exists reliably? I can’t rely on a query model as it’s not strongly consistent.

I also have a problem that the 3rd party system doesn’t guarantee the same object id, so I have to use a set of values that aren’t perfectly unique (last 4 digits of a unique number which may be null and a user-defined name). So I cannot rely directly on event tags tog et a single object. But I can rely on its parent id to be the same.

I could create a parent entity consuming ObjectCreated events and just store objectLast4Set and objectNameSet but I’m worried about an out-of-memory error as those sets may contain millions of entries.

Before axon I could just send a select to the database but now not sure.