@ -35,13 +35,15 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS;
@Slf4j
@Slf4j
@RuleNode (
@RuleNode (
type = ComponentType . ACTION ,
type = ComponentType . ACTION ,
name = "transac tion start" ,
name = "synchroniza tion start" ,
configClazz = EmptyNodeConfiguration . class ,
configClazz = EmptyNodeConfiguration . class ,
nodeDescription = "" ,
nodeDescription = "Starts synchronization of message processing based on message originator" ,
nodeDetails = "" ,
nodeDetails = "This node should be used together with \"synchronization end\" node. \n This node will put messages into queue based on message originator id. \n" +
"Subsequent messages will not be processed until the previous message processing is completed or timeout event occurs.\n" +
"Size of the queue per originator and timeout values are configurable on a system level" ,
uiResources = { "static/rulenode/rulenode-core-config.js" } ,
uiResources = { "static/rulenode/rulenode-core-config.js" } ,
configDirective = "tbNodeEmptyConfig" )
configDirective = "tbNodeEmptyConfig" )
public class TbTransac tionBeginNode implements TbNode {
public class TbSynchroniza tionBeginNode implements TbNode {
private EmptyNodeConfiguration config ;
private EmptyNodeConfiguration config ;
@ -51,7 +53,7 @@ public class TbTransactionBeginNode implements TbNode {
}
}
@Override
@Override
public void onMsg ( TbContext ctx , TbMsg msg ) throws ExecutionException , InterruptedException , TbNodeException {
public void onMsg ( TbContext ctx , TbMsg msg ) {
log . trace ( "Msg enters transaction - [{}][{}]" , msg . getId ( ) , msg . getType ( ) ) ;
log . trace ( "Msg enters transaction - [{}][{}]" , msg . getId ( ) , msg . getType ( ) ) ;
TbMsgTransactionData transactionData = new TbMsgTransactionData ( msg . getId ( ) , msg . getOriginator ( ) ) ;
TbMsgTransactionData transactionData = new TbMsgTransactionData ( msg . getId ( ) , msg . getOriginator ( ) ) ;
@ -63,7 +65,7 @@ public class TbTransactionBeginNode implements TbNode {
ctx . tellNext ( startMsg , SUCCESS ) ;
ctx . tellNext ( startMsg , SUCCESS ) ;
} , endMsg - > log . trace ( "Transaction ended successfully...[{}][{}]" , endMsg . getId ( ) , endMsg . getType ( ) ) ,
} , endMsg - > log . trace ( "Transaction ended successfully...[{}][{}]" , endMsg . getId ( ) , endMsg . getType ( ) ) ,
throwable - > {
throwable - > {
log . error ( "Transaction failed! [{}][{}]" , tbMsg . getId ( ) , tbMsg . getType ( ) , throwable ) ;
log . trace ( "Transaction failed! [{}][{}]" , tbMsg . getId ( ) , tbMsg . getType ( ) , throwable ) ;
ctx . tellFailure ( tbMsg , throwable ) ;
ctx . tellFailure ( tbMsg , throwable ) ;
} ) ;
} ) ;
}
}