@@ -428,7 +428,7 @@ Activity.prototype.resume = function resume() {
428428} ;
429429
430430/**
431- * Discard the activity. Stops execution if running and discards outbound flows .
431+ * Discard the activity. Stops execution if running; the activity leaves without taking any outbound flow .
432432 * @param {Record<string, any> } [discardContent] Optional content propagated with the discard
433433 * @returns {void }
434434 */
@@ -677,12 +677,8 @@ Activity.prototype._onInbound = function onInbound(routingKey, message) {
677677 message : content . message ,
678678 inbound,
679679 } ) ;
680- case 'flow.discard' :
681680 case 'activity.discard' : {
682- let discardSequence ;
683- if ( content . discardSequence ) discardSequence = content . discardSequence . slice ( ) ;
684- const context = { inbound, discardSequence } ;
685- return this [ K_FLAGS ] . isParallelGateway ? this . run ( context ) : this . _runDiscard ( context ) ;
681+ return this . _runDiscard ( { inbound } ) ;
686682 }
687683 }
688684} ;
@@ -721,7 +717,6 @@ Activity.prototype._onInboundEvent = function onInboundEvent(routingKey, message
721717 }
722718 case 'association.take' :
723719 case 'flow.take' :
724- case 'flow.discard' :
725720 return inboundQ . queueMessage ( fields , cloneContent ( content ) , properties ) ;
726721 }
727722} ;
@@ -918,7 +913,7 @@ Activity.prototype._onExecutionMessage = function onExecutionMessage(routingKey,
918913
919914 switch ( routingKey ) {
920915 case 'execution.outbound.take' : {
921- return this . _doOutbound ( message , false , ( err , outbound ) => {
916+ return this . _doOutbound ( message , ( err , outbound ) => {
922917 message . ack ( ) ;
923918 if ( err ) return this . emitFatal ( err , content ) ;
924919 broker . publish ( 'run' , 'run.execute.passthrough' , cloneContent ( content , { outbound } ) ) ;
@@ -958,12 +953,12 @@ Activity.prototype._ackRunExecuteMessage = function ackRunExecuteMessage() {
958953Activity . prototype . _doRunLeave = function doRunLeave ( message , isDiscarded , onOutbound ) {
959954 const { content, properties } = message ;
960955 const correlationId = properties . correlationId ;
961- if ( content . ignoreOutbound ) {
956+ if ( isDiscarded || content . ignoreOutbound ) {
962957 this . broker . publish ( 'run' , 'run.leave' , cloneContent ( content ) , { correlationId } ) ;
963958 return onOutbound ( ) ;
964959 }
965960
966- return this . _doOutbound ( cloneMessage ( message ) , isDiscarded , ( err , outbound ) => {
961+ return this . _doOutbound ( cloneMessage ( message ) , ( err , outbound ) => {
967962 if ( err ) {
968963 return this . _publishEvent ( 'error' , { ...content , error : err } , { correlationId } ) ;
969964 }
@@ -982,16 +977,14 @@ Activity.prototype._doRunLeave = function doRunLeave(message, isDiscarded, onOut
982977} ;
983978
984979/** @internal */
985- Activity . prototype . _doOutbound = function doOutbound ( fromMessage , isDiscarded , callback ) {
980+ Activity . prototype . _doOutbound = function doOutbound ( fromMessage , callback ) {
986981 const outboundSequenceFlows = this [ K_FLOWS ] . outboundSequenceFlows ;
987982 if ( ! outboundSequenceFlows . length ) return callback ( null , [ ] ) ;
988983
989984 const fromContent = fromMessage . content ;
990985
991986 let outboundFlows ;
992- if ( isDiscarded ) {
993- outboundFlows = outboundSequenceFlows . map ( ( flow ) => formatFlowAction ( flow , { action : 'discard' } ) ) ;
994- } else if ( fromContent . outbound ?. length ) {
987+ if ( fromContent . outbound ?. length ) {
995988 outboundFlows = outboundSequenceFlows . map ( ( flow ) => formatFlowAction ( flow , fromContent . outbound . filter ( ( f ) => f . id === flow . id ) . pop ( ) ) ) ;
996989 }
997990
0 commit comments