Camunda/Activiti process loops endessly in JavaDelegate's - infinite-loop

I have problem with camunda process that looks like this.
This process loops endlessly in an non deterministic way in steps SetId and CreateObjectsForId (both are JavaDelegates).
I am using camunda 7.5.
I have some BaseJavaDelegate implemented like:
#Override
public void execute( DelegateExecution aExecution ) throws Exception
{
logBefore( aExecution );
try
{
executeInTry( aExecution );
}
catch( Throwable aEx )
{
aEx.printStackTrace();
throw new BpmnError( "GENERIC_ERROR_CODE", aEx.getMessage() );
}
logAfter( aExecution );
}
Log from example execution:
01.06.2017 15:32:53,902;pool-6-thread-2:...wf.base.BaseJavaDelegate;callExecuteInTry;DEBUG;
Starting task:
ProcessDefinitionId: ...Process1:1:1
ProcessInstanceId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ExecutionId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ActivityId: SetId
TransactionId: null
...
01.06.2017 15:32:54,664;pool-6-thread-2:...wf.base.BaseJavaDelegate;callExecuteInTry;DEBUG;
Ended task:
ProcessDefinitionId: ...Process1:1:1
ProcessInstanceId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ExecutionId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ActivityId: SetId
TransactionId: null
...
Starting task:
ProcessDefinitionId: ...Process1:1:1
ProcessInstanceId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ExecutionId: d161958b-46ce-11e7-8483-005056b37c6b
ActivityId: CreateObjectsForId
TransactionId: null
...
01.06.2017 15:37:53,886;pool-6-thread-3:...wf.base.BaseJavaDelegate;callExecuteInTry;DEBUG;
Starting task:
ProcessDefinitionId: ...Process1:1:1
ProcessInstanceId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ExecutionId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ActivityId: SetId
TransactionId: null
...
01.06.2017 15:37:53,893;pool-6-thread-3:...wf.base.BaseJavaDelegate;callExecuteInTry;DEBUG;
Ended task:
ProcessDefinitionId: ...Process1:1:1
ProcessInstanceId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ExecutionId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ActivityId: SetId
TransactionId: null
...
Starting task:
ProcessDefinitionId: ...Process1:1:1
ProcessInstanceId: ae2ecf43-46ce-11e7-8483-005056b37c6b
ExecutionId: d161958b-46ce-11e7-8483-005056b37c6b
ActivityId: CreateObjectsForId
TransactionId: null
From log you can see that SetId was started second time while CreateObjectsForId never finished.
No exception is thrown during this execution.
Also previous steps are all executed in the same thread but when the loop begins process starts using another thread/two threads.
I have tried to bypass this problem by designing process like this.
This time implementation of SetId step knows that it was entered for the second time and with exclusive gate process should go further.
Unfortunately the process still loops! No exception from my code. No OptimisticLockException. No any other exception from camunda.
I have no clue what else can cause process to loop like this.

Maybe I'm missing something, but it looks like you have recursive code here.
Your delegate executes, and then you take the execution and execute it again in executeInTry()....rinse and repeat.
Am I missing something?
Greg

I have found solution to my problem.
I have been running embedded camunda engine.
Once, I decided to try running the same code on application server (wildfly in my case). Now I got clear messages in log that my transactions we just taking too long. Here you can find solution of this problem (transactions timeout and jobs-executor lockTimeInMillis)

Related

symfony 3 console command list in controller

As I am not sure how to describe it, I didn't found any results in google or stack.
I would like to list all available console commands (which are callable by using the bin/console) with a Controller-Action so that I can forward a list of all commands to twig.
How can I realize this ?
Interesting question. You can of course just run the console command itself and capture the list of commands. Might actually be the best way.
However, there is a service called console.command_loader which has a method called getNames which does indeed return a list of command names. It implements CommandLoaderInterface.
Originally I tried to create an alias so it could be injected into an action method:
services:
Symfony\Component\Console\CommandLoader\CommandLoaderInterface:
alias: console.command_loader
But I kept getting console.command_loader not found which was puzzling since debug:container shows it. The service was tagged with container.no_preload which might have something to do with it. Not sure.
So I went and just defined the controller service:
services:
App\Controller\CommandController:
tags:
- 'controller.service_arguments'
arguments:
- '#console.command_loader'
And somewhat to my surprise it worked.
class CommandController extends AbstractController
{
public function __construct(private CommandLoaderInterface $cl)
{
}
#[Route('/commands', name: 'app_commands')]
public function commands(): Response
{
$names = $this->cl->getNames();
dump($names);
// I happen to have a command called app:init
$initCommand = $this->cl->get('app:init');
dump($initCommand->getDescription());
//return $this->render('default/index.html.twig', [
// 'controller_name' => 'DefaultController ' . 'Commands',
//]);
}
}
This was all done in Symfony 6. Did not happen to have a Symfony 3 app handy. Your first step would be to confirm that Symfony 3 also has the service with bin/console debug:container console.command_loader. If it does not have such a service then poke around a bit and see if it has something similar.

Cake Clean task is skipped on cake build

Brand-new Cake project, build.cake written as in Setting Up A New Project, added to a net5.0 console application.
When running dotnet cake, the task Clean is silently skipped by runner.
I ran dotnet cake --target="Clean" --verbosity=normal and received this:
Error: One or more errors occurred. (Could not reach target 'Clean' since it was skipped due to a criteria.)
No idea what criteria is skipping the task.
My build.cake:
var target = Argument("target", "Test");
var configuration = Argument("configuration", "Release");
///////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////
Task("Clean")
.WithCriteria(c => HasArgument("rebuild"))
.Does(() =>
{
CleanDirectory($"./LucroMei/bin/{configuration}");
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreBuild("./LucroMei.sln", new DotNetCoreBuildSettings
{
Configuration = configuration,
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
DotNetCoreTest("./LucroMei.sln", new DotNetCoreTestSettings
{
Configuration = configuration,
NoBuild = true,
});
});
///////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////
RunTarget(target);
The Clean task in your script is defined with criteria, take a look at this line:
.WithCriteria(c => HasArgument("rebuild"))
It means that the task will run only in case the condition is specified. The condition is HasArgument("rebuild"), which is trying to find the argument named rebuild among other arguments specified.
If you run your script like this, the Clean target will run:
dotnet cake --rebuild
The error message is very clear:
Could not reach target 'Clean' since it was skipped due to a criteria
Looking at your Clean target, it has a criteria expectation:
Task("Clean")
.WithCriteria(c => HasArgument("rebuild")) // <<#<<#<<#<<#<<#<<#####
.Does(() => { ... });
This means that your Clean criteria will only run if you provide the argument --rebuild:
dotnet cake --target="Clean" --verbosity=normal --rebuild

Get " Class is not registered:" exception during Gremlin Query

I'm using Gremlin to connect with Janusgraph. Right now, I'd like to program a gremlin query statement to get specific Vertex by label with ignoring case-sensitive. So, my query like this:
g.V(vertexId).inE(edgeLabel).outV().filter(it -> it.get().label().equalsIgnoreCase(label)) ;
However, the execution caused a exception:
java.lang.IllegalArgumentException: Class is not registered: com.demo.service.kg.KGService$$Lambda$506/1884099229
Note: To register this class use: kryo.register(com.demo.service.kg.KGService$$Lambda$506/1884099229.class);
My configuration is:
hosts: [localhost]
port: 8182
connectionPool: { maxContentLength: 7000000 }
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0,
config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry],
serializeResultToString: true}}
Is there anyone knows what is going on?
Lambdas will not serialize that way. You have to submit them as strings
g.V(vertexId).inE(edgeLabel).outV().filter(
Lambda.predicate("it -> it.get().label().equalsIgnoreCase(label)")) ;

Symfony Workflow initial_place parameter not working

workflow.yaml:
framework:
workflows:
test_workflow:
type: 'workflow'
marking_store:
type: 'single_state'
arguments:
- 'currentPlace'
supports:
- App\Entity\Call
initial_place: draft
places:
- draft
- ok
- notok
transitions:
go:
from: draft
to: ok
reject:
from: draft
to: notok
My Controller:
public function twf(Registry $workflows){
$c = new Call();
$workflow = $workflows->get($c);
return $this->render('page/twf.html.twig',[
'cp' => $c->getCurrentPlace()
]);
}
It just shows nothing , but when applying the Go transition , it displays the 'ok' which is expected , I wonder why it's not taking the configured initial_place when the Call object is first initiated !
Any hints ?
I think it only sets the state to the initial after something triggers it. Requesting the workflow object is not enough.
Try calling getMarking, it should be set after that... you can see the set part here: https://github.com/symfony/workflow/blob/master/Workflow.php#L63

Catch swiftmailer exception in Symfony2 dev env controller

Im not sure why Im not catching exceptions from Swiftmailer in my controller. What am I doing wrong, or missing?
In a controller I have:
try {
$this->get('mailer')->send($email);
}
catch (\Swift_TransportException $e) {
$result = array(
false,
'There was a problem sending email: ' . $e->getMessage()
);
}
It seems to get caught by Symfony before it gets to my code, so instead of being able to handle the error myself I get the standard 500 page with
Swift_TransportException: Connection could not be established
If the email can't be sent there is no need for the application to halt as the email isn't critical - I just want to issue a notice.
Maybe there's a way to disable Symfonys catching of certain exceptions or for certain Controllers?
When you do $this->container->get("mailer")->send($email); the email message is not being sent at that point if you have spooling turned on. See http://symfony.com/doc/current/cookbook/email/spool.html
If you have the default setting of spool: { type: memory }, the \Swift_TransportException will be thrown during the kernel termination phase, after your controller has exited.
One way around this is to turn off the spooling (but then your users might have to wait while the email is sent), or you can make your own eventlistener to handle the exception. http://symfony.com/doc/current/cookbook/service_container/event_listener.html
You can try overriding the Twig Exception Handler in config.yml:
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
exception_controller: MyBundleName:Exception:show
You then create an Exception class which extends:
Symfony\Bundle\TwigBundle\Controller\ExceptionController
Read the source code of that file and then override the methods to switch which template is rendered when the Exception type is Swift_TransportException
You can do that by setting a class variable in showAction() and passing it to findTemplate()
showAction:
$this->exceptionClassName = $exception->getClass();
findTemplate:
if (!$debug && $this->exceptionClassName == 'MyBundle\Exception\GenericNotFoundException') {
return 'BundleName:Exception:generic404.html.twig';
}
For more information, I recommend the KNPUniversity Symfony Screencasts.

Resources