If 2 activities have same activityId, will it cause some problem?

if 2 activities have same activityId, will it cause some problem?

Can you explain the problem? Activity id (if you don’t explicitly set it) is generated by service when you request its invocation in your workflow code. Do you explicitly set the id for your use case?

yes, i set it when execute a activity


my case is little complexed, my flow relay on some unreliable services, I need to show my user that “the activity failed because the outer services, concat to the owner and fix it then u can retry the activity”

so I don’t want to set an infinity retryPolicy , case I want to notify my user that there is sth wrong with outer service, go fix it or the activity will never succeed

there are 2 key points

  • user can be notified when the activity turns err
  • when the outer service is fixed, user can retry the activity

to archive it , I need keep the workflow running, cause if it’s failed I can’t retry the activity properly

so I block the activity err to return to the workflow, when an activity is err, it will waiting for a signal which tell how to handle the err, retry/skip/throw.

it look like below

	// set activity id
	activityOptions := workflow.GetActivityOptions(ctx)
	activityOptions.ActivityID = generateIdBySideEffect(ctx)
	ctx = workflow.WithActivityOptions(ctx, activityOptions)

	err := workflow.ExecuteActivity(ctx, activity, args...).Get(ctx, &result)
	for err != nil {
		// handle err , don't return err to flow
		// if err, waiting for signal to skip error or reExecute the activity
		receiveChannel := workflow.GetSignalChannel(ctx, fmt.Sprintf("errorAction"))
		errAction := ErrAction{}
		receiveChannel.Receive(ctx, &errAction)

		switch errAction.Action {
		case SkipAction:
			return nil
		case ReExecuteAction:
			// reExecute the activity
			err = workflow.ExecuteActivity(ctx, activity, args).Get(ctx, &result)
		case ThrowAction:
			return err
		}
	}

my question is that

  1. if 2 activity have same activityId, will it cause problem?
  2. it there an easy way to archive my case points?
  1. if 2 activity have same activityId, will it cause problem?

Activity id can be reused. It is not allowed to run activities in parallel with the same id.

it there an easy way to archive my case points?

What you are doing is OK. You can write a nice struct that encapsulates the code you posted. Then it can be reused in many parts of your workflow.