Fixes #3407: Prevent NPE when publishing event

Fixes #3407: Prevent NPE
How can and endpoint end up without a uuid?

And if isn't fully initialized yet, can it gets an uuid over time? So at some point in time you are using the endpoint.hash as order key and moments later you are using the uuid as key. This means that you can't guarantee ordering.

It could very well be that I'm totally wrong btw.

Perhaps it would be better to move the logic to the endpoint -> endpoint.getOrderkey(). Current implementation is very procedural and leave logic in strange places.