# Temporal Activity Retry Policy

**URL:** <https://community.temporal.io/t/temporal-activity-retry-policy/9211>\
**Category:** Community Support\
**Tags:** go-sdk, general-impl\
**Created:** [August 16, 2023, 11:43am UTC](https://community.temporal.io/t/temporal-activity-retry-policy/9211 "2023-08-16T11:43:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaustubh.jadhav](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/kaustubh.jadhav/32/4174_2.png) [@kaustubh.jadhav](https://community.temporal.io/u/kaustubh.jadhav)\
**Post date:** [August 16, 2023, 11:43am UTC](https://community.temporal.io/t/temporal-activity-retry-policy/9211/1 "2023-08-16T11:43:02Z")

</div>

> [@Activity retries without exception](https://community.temporal.io/t/activity-retries-without-exception/2699/12):
>
> Could you please help me understand how can we achieve the same in Golang? retryPolicy := &temporal.RetryPolicy{ InitialInterval: time.Second, BackoffCoefficient: 2, MaximumInterval: time.Minute, MaximumAttempts: 10, } options := workflow.ActivityOptions{ StartToCloseTimeout: time.Minute \* 5, RetryPolicy: retryPolicy, } ctx = workflow.WithActivityOptions(ctx, options) logger.Info("starting workflow!") err := workflow.ExecuteActivity( ctx, Activity\_1, …

Could you please help me understand how can we achieve the same in Golang?

```auto
retryPolicy := &temporal.RetryPolicy{
		InitialInterval: time.Second,
		BackoffCoefficient: 2,
		MaximumInterval: time.Minute,
		MaximumAttempts: 10,
	}
	options := workflow.ActivityOptions{
		StartToCloseTimeout: time.Minute * 5,
		RetryPolicy: retryPolicy,
	}
	ctx = workflow.WithActivityOptions(ctx, options)

	logger.Info("starting workflow!")
	
	err := workflow.ExecuteActivity(
		ctx,
		Activity_1,
		configuration,
		workflow.GetInfo(ctx).WorkflowStartTime,
	).Get(
		ctx,
		nil,
	)
	if err != nil {
		return nil, err
	}

	err := workflow.ExecuteActivity(
		ctx,
		Activity_2,
		configuration,
		workflow.GetInfo(ctx).WorkflowStartTime,
	).Get(
		ctx,
		nil,
	)
	if err != nil {
		return nil, err
	}

	err := workflow.ExecuteActivity(
		ctx,
		Activity_3,
		configuration,
		workflow.GetInfo(ctx).WorkflowStartTime,
	).Get(
		ctx,
		nil,
	)
	if err != nil {
		return nil, err
	}

```

Here, the Activities named as Activity\_1, Activity\_2, and Activity\_3 would be retried 10 times in case of failure, since we have configured it as

```auto
MaximumAttempts: 10,

```

I want to do something like, I don’t want Activity\_3 to be retried at all. I just want it to run once, in case of failure.

Also, I don’t want to declare the retry policy for Activity\_3 again.

How can I achieve the same?

Is there any way, I can pass some or any argument to the workflow.ExecuteActivty() method to avoid the retried completely?

Any pointers or suggestions would help thanks.

---

<div class="post-metadata">

**Author:** ![tomwheeler](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tomwheeler/32/5441_2.png) [@tomwheeler](https://community.temporal.io/u/tomwheeler)\
**Post date:** [August 17, 2023, 10:13pm UTC](https://community.temporal.io/t/temporal-activity-retry-policy/9211/2 "2023-08-17T22:13:21Z")

</div>

The way to achieve this is to define a different RetryPolicy (i.e., one which doesn’t allow any retries) that you’ll associate with the `ExecuteActivity` call for `Activity_3`.

Since the RetryPolicy is used to create the `workflow.Context` instance (`ctx`) passed into that `ExecuteActivity` call, this means that you’ll create one (which uses the original policy) when calling `Activity_1` and `Activity_2`, and a different one when calling `Activity_3`.

I apologize that I don’t have a code sample readily available, but hopefully that explanation will help.
