Bulk Aggregate
El propósito del Bulker Aggregate es crear bulks únicos o recurrentes, validando y agregando componentes que serán usados por el Bulk Producer para crear el archivo de bulk.
Single Bulk Aggregate
El Single Bulk aggregate es un componente cuyo propósito es crear un nuevo bulk, agregar componentes de bulk y asegurarse de que esos componentes sean válidos. Después de que el aggregate recopila todos los componentes del bulk, puede iniciarse el bulking.
Interfaz
La interfaz BulkAggregate se define como sigue.
public interface BulkAggregate {
CompletionStage<BulkIdResponse> createBulk(CreateBulkCommand command); (1)
CompletionStage<BulkComponentIdResponse> addComponent(AddComponentCommand command); (2)
CompletionStage<BulkComponentIdResponse> addComponent(AddComponentWithAutoCreateCommand command); (3)
CompletionStage<Response> updateComponent(UpdateComponentCommand command); (4)
CompletionStage<Response> removeComponent(RemoveComponentCommand command); (5)
CompletionStage<Response> closeBulk(CloseBulkCommand command); (6)
CompletionStage<Response> openBulk(OpenBulkCommand command); (7)
CompletionStage<Response> finaliseBulk(FinaliseBulkCommand command); (8)
CompletionStage<BulkReportResponse> getBulkReport(GetBulkReportCommand command); (9)
CompletionStage<Response> terminateBulk(TerminateBulkCommand command); (10)
CompletionStage<Response> rejectBulk(RejectBulkCommand command); (11)
CompletionStage<Response> archiveBulk(ArchiveBulkCommand command); (12)
CompletionStage<Response> completeBulk(CompleteBulkCommand command); (13)
}
| 1 | createBulk Crea un nuevo bulk.
|
| 2 | addComponent Agrega un nuevo componente al bulk aggregate. El primer componente debe ser un componente raíz.
|
| 3 | addComponent Agrega un nuevo componente al bulk aggregate con funcionalidad de auto-creación del bulk. Es decir, si el bulk con el bulkId pasado no existe, se creará y se generará un componente raíz mediante ComponentGenerator antes de añadir el nuevo componente.
|
| 4 | updateComponent Actualiza el componente que está presente en el aggregate con el nuevo contenido.
|
| 5 | removeComponent Elimina el componente que está presente en el aggregate.
|
| 6 | closeBulk Cierra el aggregate, impidiendo al cliente eliminar y agregar nuevos componentes, pero permite actualizar componentes que ya están en el aggregate.
|
| 7 | openBulk Reabre el aggregate que está cerrado.
|
| 8 | finaliseBulk El punto de no retorno, esta es la señal para comenzar a procesar los datos en el aggregate y realizar el bulking.
|
| 9 | getBulkReport Devuelve un BulkReportResponse que contiene información sobre el bulk actual. |
| 10 | terminateBulk Elimina un bulk completo que está presente en el aggregate.
|
| 11 | rejectBulk Elimina el archivo de bulk producido después de que se haya realizado la finalización. El comando solo se procesará con éxito si el Bulk está en estado finalizado y si el archivo producido está presente. Se recomienda que este proceso se active después de recibir el evento BulkFinalisedNotification.
|
| 12 | archiveBulk Archiva el archivo de bulk producido después de que se haya realizado la finalización. El comando solo se procesará con éxito si el Bulk está en estado finalizado y si el archivo producido está presente. Se recomienda que este proceso se active después de recibir el evento BulkFinalisedNotification.
|
| 13 | completeBulk Completa el bulk finalizado; después de completar el bulk, solo se puede llamar al método getBulkReport. |
Recurring Bulk Aggregate
Recurring Bulk Aggregate es un componente para crear un bulk recurrente. Es responsable de agregar componentes a un Bulk Aggregate actualmente abierto, y cuando ese Bulk Aggregate se finaliza por cualquier motivo, creará un nuevo Bulk Aggregate con un componente raíz y le reenviará los componentes.
Interfaz
La interfaz RecurringBulkAggregate se define como sigue.
public interface RecurringBulkAggregate {
CompletionStage<Response> configureBulk(ConfigureBulkCommand command); (1)
CompletionStage<RecurringBulkComponentIdResponse> addComponent(AddComponentCommand command); (2)
CompletionStage<CurrentOpenBulkResponse> getCurrentOpenBulk(GetCurrentOpenBulkCommand command); (3)
}
| 1 | createBulk se usa para crear un nuevo bulk recurrente.
|
| 2 | addComponent se usa para agregar un nuevo componente al bulk abierto actual.
|
| 3 | getCurrentOpenBulk se usa para recuperar el bulk recurrente actual
|
Qué necesitas implementar
Dado que el recurring bulk aggregate es responsable de crear un nuevo single bulk, también es responsable de generar el componente raíz para el single bulk creado, y el cliente solo puede enviar componentes que se agregarán como componentes hijo de ese componente raíz. Los clientes necesitarán crear una implementación de ComponentGenerator que será responsable de la generación de un componente raíz de single bulk creado por el recurring bulk aggregate.
public interface ComponentGenerator {
String generateComponent(String specificationName); (1)
}
| 1 | generateComponent se usa para crear un componente raíz para el single bulk creado por el recurring bulk.
|
Códigos de error
Cuando un cliente envía comandos inválidos, se devolverá una respuesta con resultado FAILURE junto con el Error.
Lista de códigos de error:
| Error | Message | Description | For Command | Aggregate type |
|---|---|---|---|---|
AC01 |
Parent id present for root component |
Root component can’t have a parent |
AddComponentCommand |
Single |
AC02 |
Parent doesn’t exist |
Returned if the parent is not present in the bulk aggregate (doesn’t apply to root component) |
AddComponentCommand |
Single |
AC03 |
Path not valid or not present in the BulkSpecification |
Returned if component path is not defined in the BulkSpecification |
AddComponentCommand |
Single |
AC04 |
Content not present |
Returned if content is null or empty |
AddComponentCommand |
Single |
AC05 |
Bulk auto closed |
Returned if bulk is auto closed |
AddComponentCommand |
Single |
AC06 |
Bulk component with the same id already exists |
Returned if component with the same id is already added to bulk aggregate |
AddComponentCommand |
Single |
UC01 |
Component doesn’t exist |
Component with BulkComponentId not present in the Bulk Aggregate |
UpdateComponentCommand |
Single |
UC02 |
Content not present |
Returned if content is null or empty |
UpdateComponentCommand |
Single |
RC01 |
Component doesn’t exist |
Component with BulkComponentId not present in the Bulk Aggregate |
RemoveComponentCommand |
Single |
RC02 |
Root component can’t be deleted |
Returned if component can’t be removed because it is a root component |
RemoveComponentCommand |
Single |
RC03 |
Component has child components |
Returned when component can’t be removed because it has child components |
RemoveComponentCommand |
Single |
CS01 |
Failed to save to component store |
If a save/update fails to the component store |
On any command that adds or updates components |
Single |
CS02 |
Failed to delete from component store |
If a delete fails from the component store |
RemoveComponentCommand |
Single |
SS01 |
Failed to retrieve bulk state |
If it fails to retrieve persisted bulk state |
During bulk actor creation |
Single |
RB01 |
Recurring bulk id not valid |
Returned if recurring bulk id is not valid |
CreateBulkCommand |
Recurring |
RB02 |
Recurring bulk specification not valid |
Returned if BulkSpecification is not valid. |
CreateBulkCommand |
Recurring |
RB03 |
Bulk marked as closed |
The command is not supported in the current state |
On any command other than finalise |
Recurring |
RB04 |
Recurring bulk not configured |
The command is not supported in the current state |
GetCurrentOpenBulk |
Recurring |
RB05 |
No Current Open Bulk |
The command is not supported in the current state |
GetCurrentOpenBulk |
Recurring |
RB06 |
New bulk creation in progress |
The command is not supported in the current state |
AddComponentWithAutoCreate, RegisterChildBulkWithAutoCreate |
Recurring |
NSC01 |
Command is not supported |
The command is not supported in the current state |
On any command |
Idempotencia
Para hacer cumplir la idempotencia y evitar agregar dos componentes iguales al bulk aggregate, el cliente debe establecer el id del componente al enviar comandos AddComponent al bulker.
Dado que el bulk aggregate no se preocupa por el contenido del componente, si el cliente envía dos componentes con el mismo contenido pero con ids de componente diferentes, ambos componentes serían aceptados.
Implementaciones
Como con otras bibliotecas de IPF, las implementaciones por defecto para los casos de uso más comunes ya están proporcionadas.