sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

[Bug] withEnableSessionWorker causes to ActivityNotRegisteredError

Open mixadior opened this issue 4 years ago • 3 comments

Describe the bug

If worker started with ->withEnableSessionWorker(true) requesting any activity from it causes ActivityNotRegisteredError

To Reproduce

php worker


<?php

require_once __DIR__."/vendor/autoload.php";

use NetworkRequestTemporalPhpServices\Services\RequestLight\GuzzleRequestExecutor;
use NetworkRequestTemporalPhpServices\Services\RequestLight\RequestResultDto;
use Temporal\Activity\ActivityInterface;
use Temporal\WorkerFactory;
use Temporal\Client\GRPC\ServiceClient;
use Temporal\Client\WorkflowClient;

$factory = WorkerFactory::create();

$workflowClient = WorkflowClient::create(ServiceClient::create('host.docker.internal:7233'));
$worker = $factory->newWorker(
    'workers_test_sessions',
    \Temporal\Worker\WorkerOptions::new()
        ->withMaxConcurrentActivityTaskPollers(8)
        ->withMaxConcurrentWorkflowTaskPollers(8)
        ->withEnableSessionWorker(true)
);

#[ActivityInterface(prefix: "test_sessions_act.")]
class SessionTestActivity {
    public function makeRequest(string $name): string
    {
        return "sessioned ".$name;
    }

}

$worker->registerActivityImplementations(new SessionTestActivity());
$factory->run();

golang workflow

package app

import (
	"errors"
	"fmt"
	"go.temporal.io/sdk/workflow"
	"strings"
	"time"
)

func Test123Workflow(ctx workflow.Context) error {
	ao2 := workflow.ActivityOptions{
		TaskQueue: "workers_test_sessions",
		ScheduleToCloseTimeout: time.Second * 60,
		ScheduleToStartTimeout: time.Second * 60,
		StartToCloseTimeout: time.Second * 60,
		HeartbeatTimeout: time.Second * 10,
		WaitForCancellation: false,
	}

	activityRunCtx2 := workflow.WithActivityOptions(ctx, ao2)

	so := &workflow.SessionOptions{
		CreationTimeout:  time.Minute,
		ExecutionTimeout: 10 * time.Minute,
	}

	sessionCtx, errSess := workflow.CreateSession(activityRunCtx2, so)
	if errSess != nil {
		return errSess
	}
	defer workflow.CompleteSession(sessionCtx)

	var t interface{}
	workflow.ExecuteActivity(sessionCtx, "test_sessions_act.makeRequest", "testname").Get(sessionCtx, &t)

	return nil
}

golang workflow worker:



// @@@SNIPSTART hello-world-project-template-go-worker
package main

import (
    "log"

    "go.temporal.io/sdk/client"
    "go.temporal.io/sdk/worker"

    "hello-world-project-template-go"
)

func main() {
    // Create the client object just once per process
    c, err := client.NewClient(client.Options{})
    if err != nil {
        log.Fatalln("unable to create Temporal client", err)
    }
    defer c.Close()
    // This worker hosts both Worker and Activity functions
    w := worker.New(c, "workers_test_sessions_worklow_q", worker.Options{})
    w.RegisterWorkflow(app.Test123Workflow)

    // Start listening to the Task Queue
    err = w.Run(worker.InterruptCh())
    if err != nil {
        log.Fatalln("unable to start Worker", err)
    }
}
// @@@SNIPEND

golang workflow starter:


// @@@SNIPSTART hello-world-project-template-go-start-workflow
package main

import (
	"context"
	"fmt"
	"log"

	"go.temporal.io/sdk/client"

	"hello-world-project-template-go"
)

func main() {
	// Create the client object just once per process
	c, err := client.NewClient(client.Options{})
	if err != nil {
		log.Fatalln("unable to create Temporal client", err)
	}
	defer c.Close()
	options := client.StartWorkflowOptions{
		TaskQueue: "workers_test_sessions_worklow_q",
	}

	we, err := c.ExecuteWorkflow(context.Background(), options, app.Test123Workflow)
	if err != nil {
		log.Fatalln("unable to complete Workflow", err)
	}
	var greeting string
	err = we.Get(context.Background(), &greeting)
	if err != nil {
		log.Fatalln("unable to get Workflow result", err)
	}
	printResults(greeting, we.GetID(), we.GetRunID())
}

func printResults(greeting string, workflowID, runID string) {
	fmt.Printf("\nWorkflowID: %s RunID: %s\n", workflowID, runID)
	fmt.Printf("\n%s\n\n", greeting)
}
// @@@SNIPEND


Expected behavior

Activity written in php (test_sessions_act.makeRquest) executed.

Screenshots/Terminal output

ActivityNotRegisteredError: unable to find activityType=test_sessions_act.makeRequest. Supported types: [internalSessionCreationActivity, internalSessionCompletionActivity]

Full workflow execution exported here: http://feodosian.com/wfd.json

Versions

  • OS: MacOS 11
  • Temporal Version 1.9.0 for golang code
  • Roadrunner 2.4
  • Docker-compose official (https://github.com/temporalio/docker-compose) with temporal 1.12

mixadior avatar Sep 13 '21 14:09 mixadior

Hi,

it's semi-bug at the moment since we exposed the configuration option for sessions ahead of the actual implementation. Since there a no exists implementation in Java SDK we will have to invent an OOP approach to sessions first. This work schedule is for later this year for 1.1.0 update of Temporal SDK.

Does your use case depend on this feature now?

JD

wolfy-j avatar Sep 13 '21 16:09 wolfy-j

Hi,

it's semi-bug at the moment since we exposed the configuration option for sessions ahead of the actual implementation. Since there a no exists implementation in Java SDK we will have to invent an OOP approach to sessions first. This work schedule is for later this year for 1.1.0 update of Temporal SDK.

thanks for explaining. As i see php-sdk is actually go-sdk bundled into roadrunner and called via some protocol from php code. I cloned roadrunner-temporal plugin code and saw here, that temporal worker created (in golang code) with session worker and session creating activity works correctly (if don't restart RR), i failed on finding problem why it doesn't register user activities.

Does your use case depend on this feature now?

Actually not, at this moment i'm investigating if i can use php-sdk, how it's documentation and examples cover cases which can meet our team if we choose it as tool for porting our php legacy code. I saw example with fileprocessing, which uses approach with separate taskqueues for every worker, i will check this approach.

mixadior avatar Sep 14 '21 09:09 mixadior

Hey @mixadior, have you tried to test this feature on the latest PHP-SDK/RR versions?

rustatian avatar Sep 01 '23 12:09 rustatian