Modifying publish server repository is not standard way to implement instead you should look into reverse replication to resolve your issue. I hope in author you are directly creating the nodes under defined path and which is permissible but not the case with publish node.
To make data correctly replicated and consitent accross all the clustered servers you have to do it throug reverse replication. For information on reverse replication plz refer below articles and previous post for information.
examples of previous discussions
I see your point, I've use reverse replication in the past for user content but is not the what I wanted in this case. BTW the register component in Geometrix uses reverse replication? I thought that it creates the user on the moment.
I've found that the problem was my session. I changed the session that I was getting from the request:
js = (JackrabbitSession) request.getResourceResolver().adaptTo(Session.class);
Instead I used a session created from a null resource resolver:
resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
js = (JackrabbitSession) resourceResolver.adaptTo(Session.class);
That did the job.