SprnigCloud 由消息觸發(fā)的輸出

2023-12-13 11:49 更新

可以通過接收消息來觸發(fā)輸出消息,如以下示例所示:

Groovy DSL。 

def dsl = Contract.make {
	description 'Some Description'
	label 'some_label'
	// input is a message
	input {
		// the message was received from this destination
		messageFrom('input')
		// has the following body
		messageBody([
				bookName: 'foo'
		])
		// and the following headers
		messageHeaders {
			header('sample', 'header')
		}
	}
	outputMessage {
		sentTo('output')
		body([
				bookName: 'foo'
		])
		headers {
			header('BOOK-NAME', 'foo')
		}
	}
}

YAML。 

# Human readable description
description: Some description
# Label by means of which the output message can be triggered
label: some_label
# input is a message
input:
  messageFrom: input
  # has the following body
  messageBody:
    bookName: 'foo'
  # and the following headers
  messageHeaders:
    sample: 'header'
# output message of the contract
outputMessage:
  # destination to which the output message will be sent
  sentTo: output
  # the body of the output message
  body:
    bookName: foo
  # the headers of the output message
  headers:
    BOOK-NAME: foo

在前面的示例中,如果在input目標(biāo)上收到了適當(dāng)?shù)南?,則將輸出消息發(fā)送到output。在消息發(fā)布者側(cè),引擎生成一個(gè)測試,將該輸入消息發(fā)送到定義的目的地。使用者方面,您可以將消息發(fā)送到輸入目標(biāo),也可以使用標(biāo)簽(示例中為some_label)來觸發(fā)消息。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)