Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire event on inventory stock change #252

Closed
odrotbohm opened this issue Jan 16, 2019 · 1 comment
Closed

Fire event on inventory stock change #252

odrotbohm opened this issue Jan 16, 2019 · 1 comment
Assignees
Labels
in: spring-customization Everything related to the Spring (Boot) integration module: inventory Inventory type: enhancement Improvements and new features
Milestone

Comments

@odrotbohm
Copy link
Member

This is useful to implement automatic triggers of re-stock, e.g. by creating a supplier order or the like.

@odrotbohm odrotbohm added this to the 7.2 milestone Jan 16, 2019
@odrotbohm odrotbohm self-assigned this Jan 16, 2019
@odrotbohm
Copy link
Member Author

Requires move of inventory to a service instead of a repository.

Can't really use Spring Data domain events as whether the events should be thrown depends on some configuration of the quantity threshold and we cannot inject a configuration properties type into an entity. Possible solution: inventory private event that signals every quantity change and an internal event listener that translates that into a threshold deceeded event.

@odrotbohm odrotbohm removed this from the 7.2 milestone Oct 14, 2019
@odrotbohm odrotbohm added in: spring-customization Everything related to the Spring (Boot) integration module: inventory Inventory type: enhancement Improvements and new features labels Dec 16, 2019
odrotbohm added a commit that referenced this issue Sep 25, 2020
Decreasing the quantity of an InventoryItem now results in an internal QuantityReduced event being published. That is listened to by InternalInventoryListeners and verified against the threshold quanity defined via salespoint.inventory.restock-threshold (defaulting to Quantity.NONE). In case the current quantity is below that threshold a publicly consumable StockShort event is published that can be used to trigger further logic.

Slightly tweaked the arrangement in Inventory event listening. The event types are now member classes of InventoryEvents. Listeners are grouped into InventoryListeners and the actual business logic executed for the OrderCompleted and OrderCanceled events has been moved into an internal InventoryManagement.

Tweaked the Moduliths setup to always include the quantity module so that the Spring Boot type binding can be used in InventoryProperties. Had to let QuantityFormatter implement Converter as well and be annotated with @ConfigurationPropertiesBinding to be picked up.

AbstractEntity now exposes ….hasId(…) for easier comparison.
odrotbohm added a commit that referenced this issue Sep 25, 2020
Missing license headers or updates to those. Trailing whitespace.
@odrotbohm odrotbohm added this to the 7.3 milestone Sep 25, 2020
odrotbohm added a commit that referenced this issue Oct 2, 2020
Letting QuantityFormatter implement Converter<String, Formatter> will cause the instance not registered as a formatter anymore for the following reason:

- Spring Boot's WebMvcAutoConfigurationAdapter.addFormatters(…) calls ApplicationConversionService.addBeans(…)
- That in turn uses an if-*else*-cascade to register the found beans in the Formatting registry. If the bean implements Converter, it will not see the call to ….addFormatter(…) anymore.

This has been filed in spring-projects/spring-boot#23576. As a workaround we now register a separate converter implementation that delegates to the formatter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: spring-customization Everything related to the Spring (Boot) integration module: inventory Inventory type: enhancement Improvements and new features
Projects
None yet
Development

No branches or pull requests

1 participant