# Temporal with MicroContainers

**URL:** <https://community.temporal.io/t/temporal-with-microcontainers/748>\
**Category:** Community Support\
**Created:** [October 14, 2020, 6:53pm UTC](https://community.temporal.io/t/temporal-with-microcontainers/748 "2020-10-14T18:53:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafacs](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/mostafacs/32/351_2.png) [@mostafacs](https://community.temporal.io/u/mostafacs)\
**Post date:** [October 14, 2020, 6:53pm UTC](https://community.temporal.io/t/temporal-with-microcontainers/748/1 "2020-10-14T18:53:35Z")

</div>

Hi,  
I implemented some workflows (Multi-tenancy every client has their set of jobs) and I used cron scheduler to run it periodically  
that used Quarkus container services.

The problem is I’m some time stop Quarkus container for redeploying. I there’s any way to register the app to temporal server and get the jobs executed again based on their schedules ?

or i have to loop over my tenants in app loading and start them again like that

```auto
        WorkflowClient client = configuration.getClient();

        WorkflowOptions workflowOptions = WorkflowOptions.newBuilder()
                .setCronSchedule(EVERY_FIVE_MINUTES)
                .setWorkflowId("getAllListings-"+1000)
                .setTaskQueue(TemporalConfiguration.TASK_QUEUE)
                .setMemo(ImmutableMap.of("action", "getAllListings", "userId", 1000))
                .setWorkflowExecutionTimeout(Duration.ofMinutes(10))
                .setWorkflowRunTimeout(Duration.ofMinutes(10))
                .setWorkflowTaskTimeout(Duration.ofMinutes(10))
                .build();

        // Create a new workflow stub per each workflow start
        GetListingWorkFlow workflow = client.newWorkflowStub(GetListingWorkFlow.class, workflowOptions);
        WorkflowExecution workflowExecution = WorkflowClient
                .start(workflow::startImport, 1000, 154, 100);

        String message = "Started process file workflow with workflowId=\"" + workflowExecution.getWorkflowId()
                + "\" and runId=\"" + workflowExecution.getRunId() + "\"";

```

Thanks

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [October 14, 2020, 7:40pm UTC](https://community.temporal.io/t/temporal-with-microcontainers/748/2 "2020-10-14T19:40:35Z")

</div>

I think I don’t understand your architecture. In the standard Temporal deployment worker processes are always up and running and periodic jobs are modeled as workflows without the need for any external schedulers.

Could you explain what exactly Quarkus is used for? For running workers periodically (why?) or for starting workflows on schedule?

---

<div class="post-metadata">

**Author:** ![mostafacs](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/mostafacs/32/351_2.png) [@mostafacs](https://community.temporal.io/u/mostafacs)\
**Post date:** [October 15, 2020, 12:50am UTC](https://community.temporal.io/t/temporal-with-microcontainers/748/3 "2020-10-15T00:50:39Z")

</div>

Thanks for your response. (I have a small experience in temporal). I used Quarkus for enabling or disable the job with REST endpoints for a particular user/tenant (also the services contain business logic implemented in Quarkus). the workflow code is existing in the same quarkus project (I mean GetListingWorkFlow.java and GetListingWorkFlowImpl.java and all activities code too). Currently, the job Is starting and completed successfully.  
I used Quarkus corn scheduling `setCronSchedule(EVERY_FIVE_MINUTES)`  
But the issue I mean happens when I want to restart the Quarkus project. I want the jobs to run in the schedule I configured before.

Is there are anyways to do that? OR Should I use Quartz to trigger the job instead of temporal scheduling?

Should store all jobs ids and status for tenant in DB and start them after the app is loading like the code i added before?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [October 15, 2020, 1:22am UTC](https://community.temporal.io/t/temporal-with-microcontainers/748/4 "2020-10-15T01:22:19Z")

</div>

If you used Temporal for scheduling then you wouldn’t need to take any action on container restart as Temporal automatically recovers the state of all workflows on any infrastructure failure.

---

<div class="post-metadata">

**Author:** ![mostafacs](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/mostafacs/32/351_2.png) [@mostafacs](https://community.temporal.io/u/mostafacs)\
**Post date:** [October 15, 2020, 2:14am UTC](https://community.temporal.io/t/temporal-with-microcontainers/748/5 "2020-10-15T02:14:41Z")

</div>

It works as expected. I have to register the app as a client to the temporal server in the Quarkus startup.  
Thanks so much.

```auto
 WorkflowServiceStubsOptions options = WorkflowServiceStubsOptions.newBuilder()
                .setTarget(.........)
                .build();

        WorkflowServiceStubs service = WorkflowServiceStubs.newInstance(options);

        client = WorkflowClient.newInstance(service);

        WorkerFactory factory = WorkerFactory.newInstance(client);
        Worker worker = factory.newWorker(TASK_QUEUE);
        worker.registerWorkflowImplementationTypes(.......); // ... others here
        worker.registerWorkflowImplementationTypes(......);

        worker.registerActivitiesImplementations(......);
        worker.registerActivitiesImplementations(......);

        factory.start();

```
