# Schedule in Java SDK

**URL:** https://community.temporal.io/t/schedule-in-java-sdk/8388
**Category:** Community Support
**Tags:** java-sdk
**Created:** [May 30, 2023, 6:16am UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388 "2023-05-30T06:16:05Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [May 30, 2023, 6:16am UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/1 "2023-05-30T06:16:05Z")

</div>

Hi Temporal team,

Does Temporal Java SDK natively supports schedule? [Workflows | Temporal Documentation](https://docs.temporal.io/workflows#limitations) says we can use the gRPC API and method create Schedule. Can you provide more information/examples for this?

---

<div class="post-metadata">

### Author: ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)
#### Post date: [May 30, 2023, 10:18am UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/3 "2023-05-30T10:18:49Z")

</div>

@Sowmya

you can use `createSchedule` method from the [WorkflowServiceStubs](https://www.javadoc.io/doc/io.temporal/temporal-serviceclient/latest/io/temporal/api/workflowservice/v1/WorkflowServiceGrpc.WorkflowServiceStub.html)

E.g.

```auto
WorkflowClient client = WorkflowClient.newInstance(service);

    ScheduleSpec.Builder interval =
        ScheduleSpec.newBuilder()
            .addInterval(
                IntervalSpec.newBuilder()
                    .setInterval(com.google.protobuf.Duration.newBuilder().setSeconds(5000).build())
                    .build());
    NewWorkflowExecutionInfo workflowExecutionInfo =
        NewWorkflowExecutionInfo.newBuilder()
            .setWorkflowType(WorkflowType.newBuilder().setName("MyWorkflow").build())
            .setTaskQueue(TaskQueue.newBuilder().setName("taskqueue").build())
            .build();
    client
        .getWorkflowServiceStubs()
        .blockingStub()
        .createSchedule(
            CreateScheduleRequest.newBuilder()
                .setScheduleId("scheduleId")
                .setRequestId("my-request")
                .setNamespace("default")
                .setSchedule(
                    Schedule.newBuilder()
                        .setSpec(interval.build())
                        .setAction(
                            ScheduleAction.newBuilder()
                                .setStartWorkflow(workflowExecutionInfo)
                                .build())
                        .build())
                .build());

```

I will try to add this to the samples-repo [[Feature Request] sample for schedule · Issue #461 · temporalio/samples-java · GitHub](https://github.com/temporalio/samples-java/issues/461)

---

<div class="post-metadata">

### Author: ![Chad\_Retz](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/chad_retz/32/1396_2.png) [@Chad\_Retz](https://community.temporal.io/u/Chad_Retz)
#### Post date: [May 30, 2023, 12:29pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/4 "2023-05-30T12:29:18Z")

</div>

> [@Sowmya](#):
>
> Does Temporal Java SDK natively supports schedule?

This is being actively worked on [here](https://github.com/temporalio/sdk-java/issues/1333) and should be done in not too long.

---

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [May 30, 2023, 12:53pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/5 "2023-05-30T12:53:24Z")

</div>

Thanks @antonio.perez for the quick reply. @Chad_Retz , Is there any estimate of when this will be available?

---

<div class="post-metadata">

### Author: ![Chad\_Retz](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/chad_retz/32/1396_2.png) [@Chad\_Retz](https://community.temporal.io/u/Chad_Retz)
#### Post date: [May 30, 2023, 1:06pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/6 "2023-05-30T13:06:02Z")

</div>

> [@Sowmya](#):
>
> Is there any estimate of when this will be available?

Not exactly. Hopefully soon (i.e. in `master` in days or weeks, not months).

---

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [May 30, 2023, 1:57pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/7 "2023-05-30T13:57:08Z")

</div>

I just now tried the above example, but facing below error:

```auto
io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown method CreateSchedule for service temporal.api.workflowservice.v1.WorkflowService
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.createSchedule(WorkflowServiceGrpc.java:3643)

```

Is there something that I’m missing here? Also, where do we specify the workflow that schedule should run? Is it the WorkflowType?

---

<div class="post-metadata">

### Author: ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)
#### Post date: [May 30, 2023, 2:04pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/8 "2023-05-30T14:04:27Z")

</div>

Yes, it is the workflow type,

I ran the code above with java-sdk 1.19.1. Which SDK are you using?

---

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [May 30, 2023, 2:17pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/9 "2023-05-30T14:17:54Z")

</div>

I had 1.15.1 earlier. Upgraded to 1.19.1 but still facing the same error.

---

<div class="post-metadata">

### Author: ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)
#### Post date: [May 30, 2023, 2:33pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/10 "2023-05-30T14:33:25Z")

</div>

that is weird,  
can you try cloning the repo and running this example [temporal\_samples-java/HelloSchedule.java at community\_8388 · antmendoza/temporal\_samples-java · GitHub](https://github.com/antmendoza/temporal_samples-java/blob/community_8388/src/main/java/io/temporal/samples/hello/HelloSchedule.java) ?

Let me know how it goes.

---

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [May 30, 2023, 3:22pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/11 "2023-05-30T15:22:57Z")

</div>

Still same error:

```auto
Exception in thread "main" io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown method CreateSchedule for service temporal.api.workflowservice.v1.WorkflowService
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
	at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.createSchedule(WorkflowServiceGrpc.java:4164)
	at io.temporal.samples.hello.HelloSchedule.main(HelloSchedule.java:59)

```

May be this is related to my temporal set up for local. I’m using following docker images:

1. elasticsearch:7.16.3
2. postgres:13
3. temporalio/auto-setup:1.16.2
4. temporalio/admin-tools:1.16.2
5. temporalio/ui:0.14.1
6. temporalio/web:1.15.0

---

<div class="post-metadata">

### Author: ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)
#### Post date: [May 30, 2023, 6:42pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/12 "2023-05-30T18:42:03Z")

</div>

I think so @Sowmya

Schedule was added in 1.17 [https://github.com/temporalio/temporal/releases/tag/v1.17.0](https://github.com/temporalio/temporal/releases/tag/v1.17.0)

Can you pull the latest version in your local environment?

---

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [May 31, 2023, 11:38am UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/13 "2023-05-31T11:38:43Z")

</div>

Worked with latest versions. Thanks

---

<div class="post-metadata">

### Author: ![Sowmya](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sowmya](https://community.temporal.io/u/Sowmya)
#### Post date: [June 12, 2023, 11:43am UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/14 "2023-06-12T11:43:42Z")

</div>

Hi @antonio.perez ,

We are good to use schedule feature from the below suggested solution in **production** , right? Wanted to confirm once.

> [@antonio.perez](#):
>
> you can use `createSchedule` method from the [WorkflowServiceStubs](https://www.javadoc.io/doc/io.temporal/temporal-serviceclient/latest/io/temporal/api/workflowservice/v1/WorkflowServiceGrpc.WorkflowServiceStub.html)

---

<div class="post-metadata">

### Author: ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)
#### Post date: [June 12, 2023, 4:15pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/15 "2023-06-12T16:15:08Z")

</div>

Yes should be ok to use schedules for prod use cases. Would make sure service is on latest version [v1.20.3](https://github.com/temporalio/temporal/releases/tag/v1.20.3)

---

<div class="post-metadata">

### Author: ![tuk](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tuk/32/4039_2.png) [@tuk](https://community.temporal.io/u/tuk)
#### Post date: [October 4, 2023, 7:16pm UTC](https://community.temporal.io/t/schedule-in-java-sdk/8388/16 "2023-10-04T19:16:01Z")

</div>

@antonio.perez Regarding the example that you have posted can you please let me know the following

1. What happens if two different `createSchedule` request is made with different `scheduleId` but same `requestId`? Will the second submit request throw error or it will be silently ignored?
2. `requestId` idempotency is applicable for only successful `createSchdule` request? I mean let’s say my first `createSchedule` request with `requestId1` fails for some reason then I can retry with same `requestId1` ?
3. In the documentation for Java SDK I can find mention of only [cron scheduler](https://docs.temporal.io/dev-guide/java/features#cron-schedule)? Can you please point me to the documentation where `scheduleId`, `requestId`, etc are explained?

Couple of other questions

1. From Java SDK can I get a list of all schedules?
2. Can I cancel a Schedule from Java SDK?
