Upgrading to v0.8
DBOS Transact Java v0.8 contains several breaking changes. These changes were made to improve the developer experience as well as how DBOS Transact Java integrates into the larger Java ecosystem. This document explains how to update your existing DBOS Java app to v0.8.
Although we cannot guarantee that v0.8 will be the final release with breaking changes, our intention is to minimize or eliminate further breaking changes in DBOS Transact Java after v0.8.
DBOS Instance API
DBOS is now an instance class instead of a static utility class.
While static methods were easier to access, they are harder to test and mock.
Furthermore, a DBOS instance API fits better into Dependency Injection based Java frameworks like Spring.
Prior to v0.8, you would configure DBOS via the static configure method:
DBOSConfig dbosConfig = DBOSConfig.defaultsFromEnv("my-app");
DBOS.configure(dbosConfig);
Now, you pass the DBOSConfig instance to directly to the DBOS constructor:
DBOSConfig dbosConfig = DBOSConfig.defaultsFromEnv("my-app");
DBOS dbos = new DBOS(dbosConfig);
DBOS implements the AutoClosable interface.
This allows DBOS to work with the try-with-resources statement
or with JUnit's @AutoClose annotation.
var dbosConfig = DBOSConfig.defaultsFromEnv("my-app");
try (var dbos = new DBOS(dbosConfig)) {
Example proxy = dbos.registerProxy(Example.class, new ExampleImpl(dbos));
dbos.launch();
proxy.workflow();
}
With this change, registering DBOS proxies becomes slightly more involved.
Previously, you could register a proxy object anytime prior to calling DBOS.launch().
Now, you must construct the DBOS instance before calling registerProxy.
Like prior releases, all proxies must be registered before calling DBOS.launch().
DBOS.registerWorkflows() is now named DBOS.registerProxy.
For plugin developers, the DBOS instance is now provided as a parameter on dbosLaunched.
For more information, see the Lifecycle Listeners documentation
DBOS API Changes
Beyond the overarching change from static to instance methods, there were assorted other minor breaking changes to the DBOS API:
DBOS.registerWorkflowswas renamed toDBOS.registerProxyDBOS.registerQueuepreviously returned theQueueobject, now it is void return- Several methods with
@Nullablereturn types have been changed to returnOptionalDBOS.getWorkflowStatus()DBOS.recv()DBOS.getEvent()
- Several methods used by plugins were moved from
DBOStoDBOSIntegration. TheDBOSIntegrationinstance can be accessed viaDBOS.integration().DBOSIntegration.registerLifecycleListenerDBOSIntegration.getRegisteredWorkflowsDBOSIntegration.getRegisteredWorkflowsInstancesDBOSIntegration.startRegisteredWorkflowDBOSIntegration.getExternalStateDBOSIntegration.upsertExternalState
DBOSIntegration.startRegisteredWorkflow was previously named DBOS.startWorkflow.
There are several DBOS.startWorkflow overloads, only the one with a RegisteredWorkflow parameter was renamed and moved.
Strongly Typed Fields
In a variety of places across the public API surface area, fields have been changed to more semantically relevant types.
For example, previously we represented both timeout and deadline as Long with semantic information encoded in the field names - i.e. timeoutMs and deadlineEpochMs.
Now, we use the more semantically aligned types of Duration for timeout and Instant for deadline.
With the change in type, we also simplified the field names to drop the semantic type information.
WorkflowStatus
statusfield was previously aString, now it's aWorkflowStateenum valuenamefield was renamedworkflowNamecreatedAtandupdatedAtchanged their type fromLongtoInstanttimeoutMswas renamedtimeoutand the type changed fromLongtoDurationdeadlineEpochMswas renameddeadlineand the type changed fromLongtoInstantstartedAtEpochMswas renamedstartedAtand the type changed fromLongtoInstant
StepInfo
startedAtEpochMswas renamedstartedAtand the type was changed fromLongtoInstantcompletedAtEpochMswas renamedcompletedAtand the type was changed fromLongtoInstant
StepOptions
intervalSecondswas renamedretryIntervaland the type was changed fromDoubletoDuration
ListWorkflowsInput
withStartTimeandwithEndTimechanged parameter type fromOffsetDateTimetoInstantwithStatuseswas renamedwithStatusand the parameter type changed fromList<String>toList<WorkflowState>withWorkflowIdwas renamedwithWorkflowIds
@Step / StepOptions Changes
In previous versions, both @Step and StepOptions had a boolean retriesAllowed field.
This field has been removed.
Additionally, the default maxAttempts field of both @Step and StepOptions has been changed to 1.
To enable retries, simply set maxAttempts to a value greater than `.
Note, as covered above, the StepOptions.intervalSeconds field was renamed to retryInterval and the type was changed to Duration.
Annotations cannot use reference types like Duration so @Step still has an intervalSeconds field of type double.
@Scheduled Removed
The @Scheduled annotation has been removed. For durable scheduled code in your app, you can use the new Schedule Management Methods.
DBOSClient Changes
DBOSClient.EnqueueOptions changed the order of the parameters for the three string constructor.
Previously, the className parameter was first and the workflowName was second.
For consistency with other DBOS APIs, these two parameters have swapped position.
Across the code base, when specifying the workflow name, class name, instance name of a registered workflow, we have the parameters in that order.
Additionally, similar to DBOS changes detailed above, DBOSClient.getWorkflowStatus and DBOS.getEvent now return Optional instead of a @Nullable value;