<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.obsidianscheduler.com/doc/index.php?action=history&amp;feed=atom&amp;title=Micronaut_Integration</id>
	<title>Micronaut Integration - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.obsidianscheduler.com/doc/index.php?action=history&amp;feed=atom&amp;title=Micronaut_Integration"/>
	<link rel="alternate" type="text/html" href="https://wiki.obsidianscheduler.com/doc/index.php?title=Micronaut_Integration&amp;action=history"/>
	<updated>2026-05-26T22:37:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.7</generator>
	<entry>
		<id>https://wiki.obsidianscheduler.com/doc/index.php?title=Micronaut_Integration&amp;diff=3926&amp;oldid=prev</id>
		<title>Craig: Created page with &quot;Though Obsidian works great on its own, Obsidian also supports seamless integration with [https://micronaut.io/ Micronaut]. This page outlines how to set up Micronaut integrat...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.obsidianscheduler.com/doc/index.php?title=Micronaut_Integration&amp;diff=3926&amp;oldid=prev"/>
		<updated>2024-12-27T22:43:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Though Obsidian works great on its own, Obsidian also supports seamless integration with [https://micronaut.io/ Micronaut]. This page outlines how to set up Micronaut integrat...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Though Obsidian works great on its own, Obsidian also supports seamless integration with [https://micronaut.io/ Micronaut]. This page outlines how to set up Micronaut integration and execute jobs which are configured as Micronaut components. &lt;br /&gt;
&lt;br /&gt;
= Dependency Injection via Micronaut =&lt;br /&gt;
&lt;br /&gt;
As of Obsidian 6.0.0, Obsidian has formalized the support and integration with your Micronaut applications, and now supports loading job implementations from the Micronaut context. Obsidian does not include any Micronaut libraries and will defer to the version and libraries you include with your application. It supports versions of Micronaut from 3.7 onward. &lt;br /&gt;
&lt;br /&gt;
Obsidian leverages Micronaut&amp;#039;s formal support including the &amp;lt;code&amp;gt;@jakarta.inject.Singleton&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;@jakarta.inject.Scope&amp;lt;/code&amp;gt; and any extensions and specializations of those annotations. It is important to note that if a job class does not have one of these annotations, &amp;#039;&amp;#039;&amp;#039;Obsidian will not use the Micronaut instance if it exists&amp;#039;&amp;#039;&amp;#039;, and will instantiate the job directly.&lt;br /&gt;
&lt;br /&gt;
Job classes which can be loaded from Micronaut can be either &amp;lt;code&amp;gt;SchedulableJob&amp;lt;/code&amp;gt; implementations or [[Implementing_Jobs#Annotation-Based_Jobs|annotated]] jobs. See [[Implementing_Jobs|Implementing Jobs]] for details on how to write and configure executable jobs. &lt;br /&gt;
&lt;br /&gt;
Micronaut will need to be started and running wherever Obsidian scheduler runtimes exist, so it is recommended that you start Obsidian from your Application class. Below is a sample Application that starts Obsidian while also ensuring the Obsidian/Micronaut integration gets started via the &amp;lt;code&amp;gt;@Import&amp;lt;/code&amp;gt;. This &amp;#039;special sauce&amp;#039; is found in the &amp;lt;code&amp;gt;com.carfey.ops.job.di.MicronautComponentLocator&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import com.carfey.ops.job.SchedulerStarter;&lt;br /&gt;
import com.carfey.ops.job.SchedulerStarter.SchedulerMode;&lt;br /&gt;
&lt;br /&gt;
import io.micronaut.context.ApplicationContext;&lt;br /&gt;
import io.micronaut.context.annotation.Import;&lt;br /&gt;
import io.micronaut.runtime.Micronaut;&lt;br /&gt;
&lt;br /&gt;
@Import(packages = {&amp;quot;com.carfey.ops.job.di&amp;quot;})&lt;br /&gt;
public class Application {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		ApplicationContext context = Micronaut.run(Application.class, args);&lt;br /&gt;
&lt;br /&gt;
		SchedulerStarter.get(SchedulerMode.EMBEDDED);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample Job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import com.carfey.ops.job.Context;&lt;br /&gt;
import com.carfey.ops.job.SchedulableJob;&lt;br /&gt;
&lt;br /&gt;
import jakarta.inject.Singleton;&lt;br /&gt;
&lt;br /&gt;
@Singleton&lt;br /&gt;
public class MyMicronautSchedulerJob implements SchedulableJob {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public void execute(Context context) throws Exception {&lt;br /&gt;
		//do something here&lt;br /&gt;
		...&lt;br /&gt;
		context.saveJobResult(&amp;quot;Job result&amp;quot;, result);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Craig</name></author>
	</entry>
</feed>