Skip to content

Commit

Permalink
HSEARCH-4132 Change outbox event property names
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever authored and yrodiere committed Mar 8, 2021
1 parent c52ac70 commit 5c722a6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
Expand Up @@ -205,15 +205,15 @@ private List<OutboxEvent> findOutboxEntries(Session session) {
return session.createQuery( "select e from OutboxEvent e order by id", OutboxEvent.class ).list();
}

private void verifyOutboxEntry(OutboxEvent outboxEvent, String entityName, String serializedId,
private void verifyOutboxEntry(OutboxEvent outboxEvent, String entityName, String entityId,
OutboxEvent.Type type, String currentRoute, String... previousRoutes) {
assertThat( outboxEvent.getEntityName() ).isEqualTo( entityName );
assertThat( outboxEvent.getSerializedId() ).isEqualTo( serializedId );
assertThat( outboxEvent.getEntityId() ).isEqualTo( entityId );
assertThat( outboxEvent.getType() ).isEqualTo( type );

byte[] serializedRoutingKeys = outboxEvent.getSerializedRoutes();
byte[] documentRoutes = outboxEvent.getDocumentRoutes();
DocumentRoutesDescriptor routesDescriptor = SerializationUtils.deserialize(
DocumentRoutesDescriptor.class, serializedRoutingKeys );
DocumentRoutesDescriptor.class, documentRoutes );

assertThat( routesDescriptor ).isNotNull();
assertThat( routesDescriptor.currentRoute().routingKey() ).isEqualTo( currentRoute );
Expand Down
Expand Up @@ -49,8 +49,8 @@ public class OutboxAdditionalJaxbMappingProducer implements org.hibernate.boot.s
" </generator>\n\r" +
" </id>\n\r" +
" <property name=\"entityName\" type=\"string\" />\n" +
" <property name=\"serializedId\" type=\"string\" />\n" +
" <property name=\"serializedRoutes\" type=\"binary\" length=\"8192\" />\n" +
" <property name=\"entityId\" type=\"string\" />\n" +
" <property name=\"documentRoutes\" type=\"binary\" length=\"8192\" />\n" +
" <property name=\"type\" >\n" +
" <type name=\"org.hibernate.type.EnumType\">\n" +
" <param name=\"enumClass\">" + OutboxEvent.Type.class.getName() + "</param>\n" +
Expand Down
Expand Up @@ -20,24 +20,25 @@ public enum Type {
}

private Integer id;
private String entityName;
private String serializedId;
private byte[] serializedRoutes;
private Type type;

private String entityName;
private String entityId;
private byte[] documentRoutes;
@Transient
private Object identifier;
private Object originalEntityId;

public OutboxEvent() {
}

public OutboxEvent(String entityName, String serializedId, DocumentRoutesDescriptor routesDescriptor, Type type,
Object identifier) {
this.entityName = entityName;
this.serializedId = serializedId;
this.serializedRoutes = SerializationUtils.serialize( routesDescriptor );
public OutboxEvent(
Type type, String entityName, String entityId, DocumentRoutesDescriptor documentRoutesDescriptor,
Object originalEntityId) {
this.type = type;
this.identifier = identifier;
this.entityName = entityName;
this.entityId = entityId;
this.documentRoutes = SerializationUtils.serialize( documentRoutesDescriptor );
this.originalEntityId = originalEntityId;
}

public Integer getId() {
Expand All @@ -48,44 +49,44 @@ public void setId(Integer id) {
this.id = id;
}

public String getEntityName() {
return entityName;
public Type getType() {
return type;
}

public void setEntityName(String entityName) {
this.entityName = entityName;
public void setType(Type type) {
this.type = type;
}

public String getSerializedId() {
return serializedId;
public String getEntityName() {
return entityName;
}

public void setSerializedId(String serializedId) {
this.serializedId = serializedId;
public void setEntityName(String entityName) {
this.entityName = entityName;
}

public byte[] getSerializedRoutes() {
return serializedRoutes;
public String getEntityId() {
return entityId;
}

public void setSerializedRoutes(byte[] serializedRoutes) {
this.serializedRoutes = serializedRoutes;
public void setEntityId(String entityId) {
this.entityId = entityId;
}

public Type getType() {
return type;
public byte[] getDocumentRoutes() {
return documentRoutes;
}

public void setType(Type type) {
this.type = type;
public void setDocumentRoutes(byte[] documentRoutes) {
this.documentRoutes = documentRoutes;
}

public Object getIdentifier() {
return identifier;
public Object getOriginalEntityId() {
return originalEntityId;
}

public void setIdentifier(Object identifier) {
this.identifier = identifier;
public void setOriginalEntityId(Object originalEntityId) {
this.originalEntityId = originalEntityId;
}

@Override
Expand All @@ -96,15 +97,15 @@ public boolean equals(Object o) {
if ( o == null || getClass() != o.getClass() ) {
return false;
}
OutboxEvent that = (OutboxEvent) o;
return type == that.type && Objects.equals( entityName, that.entityName ) && Objects.equals(
serializedId, that.serializedId ) && Arrays.equals( serializedRoutes, that.serializedRoutes );
OutboxEvent event = (OutboxEvent) o;
return type == event.type && Objects.equals( entityName, event.entityName ) && Objects.equals(
entityId, event.entityId ) && Arrays.equals( documentRoutes, event.documentRoutes );
}

@Override
public int hashCode() {
int result = Objects.hash( type, entityName, serializedId );
result = 31 * result + Arrays.hashCode( serializedRoutes );
int result = Objects.hash( type, entityName, entityId );
result = 31 * result + Arrays.hashCode( documentRoutes );
return result;
}

Expand All @@ -113,7 +114,7 @@ public String toString() {
return "OutboxEvent{" +
"type=" + type +
", entityName='" + entityName + '\'' +
", serializedId='" + serializedId + '\'' +
", entityId='" + entityId + '\'' +
'}';
}
}
Expand Up @@ -27,18 +27,18 @@ public OutboxTableSendingPlan(Session session) {

@Override
public void add(String entityName, Object identifier, String serializedId, DocumentRoutesDescriptor routes) {
events.add( new OutboxEvent( entityName, serializedId, routes, OutboxEvent.Type.ADD, identifier ) );
events.add( new OutboxEvent( OutboxEvent.Type.ADD, entityName, serializedId, routes, identifier ) );
}

@Override
public void addOrUpdate(String entityName, Object identifier, String serializedId,
DocumentRoutesDescriptor routes) {
events.add( new OutboxEvent( entityName, serializedId, routes, OutboxEvent.Type.ADD_OR_UPDATE, identifier ) );
events.add( new OutboxEvent( OutboxEvent.Type.ADD_OR_UPDATE, entityName, serializedId, routes, identifier ) );
}

@Override
public void delete(String entityName, Object identifier, String serializedId, DocumentRoutesDescriptor routes) {
events.add( new OutboxEvent( entityName, serializedId, routes, OutboxEvent.Type.DELETE, identifier ) );
events.add( new OutboxEvent( OutboxEvent.Type.DELETE, entityName, serializedId, routes, identifier ) );
}

@Override
Expand All @@ -57,7 +57,7 @@ public <R> CompletableFuture<MultiEntityOperationExecutionReport<R>> sendAndRepo
catch (RuntimeException e) {
builder.throwable( e );
builder.failingEntityReference(
entityReferenceFactory, event.getEntityName(), event.getIdentifier() );
entityReferenceFactory, event.getEntityName(), event.getOriginalEntityId() );
}
}
session.flush();
Expand Down

0 comments on commit 5c722a6

Please sign in to comment.