When the process runs to the intermediate message node, the engine will call the message service to publish the message topic. Once the message is published and enters the message queue, the interface for subscribing to the event will be called to process the business application function.

In the order swimlane process, when the process flows to the NewOrderThrowingMessage node, the message publishing operation will be initiated and the message will enter the message queue. At this time, the interface processing in the subscription event is to call the engine api interface processing that starts the process.

///<summary>

/// Message release

///</summary>

///<param name=" topic "> Topic </param>

///<param name=" line "> Content </param>

publicvoid Publish( string topic, string line)

{

var channel = MQClientFactory.CreatePublishChannel();

channel.QueueDeclare(queue: topic,

durable: false ,

exclusive: false ,

autoDelete: false ,

arguments: null );

var body = Encoding.UTF8.GetBytes(line);

channel.BasicPublish(exchange: "" ,

routingKey: topic,

basicProperties: null ,

body: body);

}

When subscribing to a message, bind the event activation interface in advance (here is the engine api interface of the message startup process):


///<summary>

/// Subscribe to messages

///</summary>

///<returns></returns>

[HttpPost]

public ResponseResult Subscribe([FromBody] MessageEntity message)

{

var result = ResponseResult.Default();

try

{

Func<MessageEntity, MessageConsumedResult> func = (new MessageDelegateService()).ConsumeMessage;

var mqService = MessageQueueServiceFactory.Create(func);

mqService.Subscribe(message.Topic);


result = ResponseResult.Success();

}

catch (System.Exception ex)

{

result = ResponseResult.Error(

string .Format( " An error occurred when subscribing message topic !{0}" , ex.Message)

);

}

return result;

}