@@ -73,8 +73,10 @@ export class RPAWorkflowCtrl extends entityCtrl<RPAWorkflow> {
7373 this . messages = "" ;
7474 WebSocketClientService . onSignedin ( async ( _user : TokenUser ) => {
7575 await this . RegisterQueue ( ) ;
76+ this . $scope . $on ( 'signin' , ( event , data ) => {
77+ this . RegisterQueue ( ) ;
78+ } ) ;
7679 if ( this . id !== null && this . id !== undefined ) {
77- console . debug ( "queuename: " + this . queuename ) ;
7880 await this . loadData ( ) ;
7981 await this . loadUsers ( ) ;
8082 } else {
@@ -83,27 +85,35 @@ export class RPAWorkflowCtrl extends entityCtrl<RPAWorkflow> {
8385 } ) ;
8486 }
8587 async RegisterQueue ( ) {
86- this . queuename = await NoderedUtil . RegisterQueue ( WebSocketClient . instance , "" , ( data : QueueMessage , ack : any ) => {
87- ack ( ) ;
88- console . debug ( data ) ;
89- if ( data . data . command == undefined && data . data . data != null ) data . data = data . data . data ;
90- this . messages += data . data . command + "\n" ;
91- if ( data . data . command == "invokecompleted" ) {
92- this . arguments = data . data . data ;
93- }
94- if ( data . data . command == "invokefailed" ) {
95- if ( data . data && data . data . data && data . data . data . Message ) {
96- this . errormessage = data . data . data . Message ;
97- } else {
98- this . errormessage = JSON . stringify ( data . data ) ;
88+ try {
89+ this . queuename = await NoderedUtil . RegisterQueue ( WebSocketClient . instance , "" , ( data : QueueMessage , ack : any ) => {
90+ ack ( ) ;
91+ console . debug ( data ) ;
92+ if ( data . data . command == undefined && data . data . data != null ) data . data = data . data . data ;
93+ this . messages += data . data . command + "\n" ;
94+ if ( data . data . command == "invokecompleted" ) {
95+ this . arguments = data . data . data ;
9996 }
97+ if ( data . data . command == "invokefailed" ) {
98+ if ( data . data && data . data . data && data . data . data . Message ) {
99+ this . errormessage = data . data . data . Message ;
100+ } else {
101+ this . errormessage = JSON . stringify ( data . data ) ;
102+ }
100103
101- }
102- if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
103- } , ( msg ) => {
104+ }
105+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
106+ } , ( msg ) => {
107+ this . queuename = "" ;
108+ console . debug ( "rabbitmq disconnected, start reconnect" )
109+ setTimeout ( this . RegisterQueue . bind ( this ) , ( Math . floor ( Math . random ( ) * 6 ) + 1 ) * 500 ) ;
110+ } ) ;
111+ console . debug ( "queuename: " + this . queuename ) ;
112+ } catch ( error ) {
104113 this . queuename = "" ;
114+ console . debug ( "register queue failed, start reconnect. " + error . message ? error . message : error )
105115 setTimeout ( this . RegisterQueue . bind ( this ) , ( Math . floor ( Math . random ( ) * 6 ) + 1 ) * 500 ) ;
106- } ) ;
116+ }
107117 }
108118 async loadUsers ( ) : Promise < void > {
109119 this . users = await NoderedUtil . Query ( "users" , { $or : [ { _type : "user" } , { _type : "role" , rparole : true } ] } , null , null , 100 , 0 , null ) ;
0 commit comments