public void call ( Message mesg , String interactionId , String btxnName ) { boolean activated = collector . session ( ) . activate ( uri , null , interactionId ) ; if ( activated ) { collector . consumerStart ( null , uri , "Test" , null , interactionId ) ; collector . setTransaction ( null , btxnName ) ; } if ( calledServices != null ) { String calledServiceName = calledServices . get ( mesg . getType ( ) ) ; // Introduce a delay related to the business logic synchronized ( this ) { try { wait ( ( ( int ) Math . random ( ) % 300 ) + 50 ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } if ( calledServiceName != null ) { Service calledService = registry . getServiceInstance ( calledServiceName ) ; String nextInteractionId = UUID . randomUUID ( ) . toString ( ) ; if ( activated ) { collector . producerStart ( null , calledService . getUri ( ) , "Test" , null , nextInteractionId ) ; } // Introduce a delay related to the latency synchronized ( this ) { try { wait ( ( ( int ) Math . random ( ) % 100 ) + 10 ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } calledService . call ( mesg , nextInteractionId , collector . getTransaction ( ) ) ; if ( activated ) { collector . producerEnd ( null , calledService . getUri ( ) , "Test" , null ) ; } } } if ( activated ) { collector . consumerEnd ( null , uri , "Test" , null ) ; } setLastUsed ( System . currentTimeMillis ( ) ) ; // Return instance to stack registry . returnServiceInstance ( this ) ; }
This method simulates calling the service .