https://github.com/flamingock/mongock-graalvm-example
Example of Mongock with GraalVM(workaround)
https://github.com/flamingock/mongock-graalvm-example
Last synced: about 1 month ago
JSON representation
Example of Mongock with GraalVM(workaround)
- Host: GitHub
- URL: https://github.com/flamingock/mongock-graalvm-example
- Owner: flamingock
- Created: 2023-11-06T22:11:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-06T22:19:33.000Z (over 2 years ago)
- Last Synced: 2025-12-14T10:15:40.275Z (8 months ago)
- Language: Java
- Size: 61.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example of workaround Mongock with GraalVM(Workorund)
## Scope
Mongock currently doesn't provide official support for Graalvm. Although it will be officially supported in the next major release,
there is a clear(and increasing) demand to have a solution in the short term.
This workaround tries to satisfies this need in the best manner possible.
## Key points
1. **The `ChangeUnitsList`**: You need to add all the ChangeUnits class you want to run(potentially, ase some of them may be already executed and will be ignored, as usual), as shown
```java
public static final List> changeUnits = Arrays.asList(
ACreateCollection.class,
BInsertDocument.class,
CInsertAnotherDocument.class
);
```
2. The feature `ChangeUnitsRegistrationFeature`. You don't need to do anything, just be aware it exists as you will need it at the image's creation time
3. `.setLockGuardEnabled(false)` in the builder.
3. `.sdkmanrc` provided. If you are not using `sdkman`, please ensure you are using graalvm
4. Ensure MongoDB is running
## Steps
- Build jar application with
```shell
./gradlew build
```
- build native image executable with
```shell
native-image --no-fallback \
--features=io.mongock.example.graalvm.ChangeUnitsRegistrationFeature \
--initialize-at-build-time=org.slf4j.simple.SimpleLogger,org.slf4j.LoggerFactory,org.slf4j.impl.StaticLoggerBinder \
-jar build/libs/graalvm-example-1.0-SNAPSHOT.jar
```
- run executable with
```shell
./graalvm-example-1.0-SNAPSHOT
```