The latest tutorial of the open source OA development platform: new version message configuration

o2oa/o2server can configure messages and channels from version 7.2.0

Message (message) means that the server generates different message content from different events during operation, and different events generate different messages. Currently, there are 52 types of events supported, as well as custom message types. The message channel refers to how to process the generated information.

The following takes creating a to-do as an example to illustrate the message processing mechanism.

type (message type)

The message types in the o2oa/o2server server are implemented by built-in coding. Version 7.2.0 supports the following 52 event types and custom message types:

  • application_create: create an application
  • application_update: update the application
  • application_delete: delete application
  • process_create: create a process
  • process_update: update process
  • process_delete: delete process
  • activity_message: There is new work via the message node
  • work_to_workCompleted: work completed to completed work
  • work_create: create a job
  • work_delete: delete work
  • workCompleted_create: create completed work
  • workCompleted_delete: delete completed work
  • task_to_taskCompleted: to-do completed transfer completed
  • task_create: create to-do
  • task_delete: delete to-do
  • task_urge: to-do is about to expire
  • task_expire: pending expiration
  • task_press: to-do reminder
  • taskCompleted_create: Created
  • taskCompleted_delete: delete completed
  • read_to_readCompleted: read to read
  • read_create: to be read and created
  • read_delete: pending deletion
  • readCompleted_create: Read and create
  • readCompleted_delete: read and deleted
  • review_create: Create a review
  • review_delete: delete review
  • meeting_invite: meeting invitation
  • meeting_delete: meeting delete
  • meeting_accept: Meeting invitation accepted
  • meeting_reject: meeting invitation rejected
  • attachment_create: Create an attachment
  • attachment_delete: delete attachment
  • attachment_share: attachment share
  • attachment_shareCancel: Attachment cancel sharing
  • attachment_editor: Attachment editable settings
  • attachment_editorCancel: The attachment can be edited and canceled
  • attachment_editorModify: The attachment can be edited and modified
  • calendar_alarm: calendar notification
  • custom_create: custom message creation
  • teamwork_taskCreate: work management task creation
  • teamwork_taskUpdate: work management task update
  • teamwork_taskDelete: delete work management tasks
  • teamwork_taskOvertime: work management task timeout
  • teamwork_chat: work management chat
  • cms_publish: content management publishing
  • cms_publish_to_creator: content management publish creator notification
  • bbs_subjectCreate: forum creation post
  • bbs_replyCreate: forum create reply
  • mind_fileSend: Mind map file sending
  • mind_fileShare: mind map file sharing
  • im_create: send IM chat message
  • custom_: custom message

custom message type

Message types starting with custom_ are recognized as custom messages.

aisle

The o2oa/o2server server message channel is used to process the received message content, the 7.2.0 version designs the following channels to process messages:

ws: webSocket message sending. pmsinner: push message. calendar: calendar dingding: nailing welink: Huawei welink zhengwudingding: government affairs nailing qiyeweixin: enterprise WeChat mpweixin: WeChat official account kafka: kafka message queue activemq: activemq message queue restful: restful call mail: mail sending api: internal excuse of the system to call jdbc: jdbc write table: self-built table hadoop: dfs write

After the message is generated, it will be sent to the channel for consumption processing.

default allocation

By default, some types and channels of messages (such as: task_create: to-do creation) are configured, and functions such as to-do notifications have been implemented by default. Most messages will be automatically processed through the default configuration.

The default configuration will send the creation to-do message through webSocket, pmsinner, dingding, welink, zhengwudingding, qiyeweixin, mpweixin.

Subsequent demonstrations of several typical message usage scenarios

Scenario: Create to-do messages for email notifications

  1. Create a new mail channel

Select "Mail" to configure smtp, the picture shows a sample configuration of Tencent Enterprise Mail, set the name of the channel as "consumer_mail"

3. Add a channel, add the channel just created to the task_create message type

So far, when there is a to-do creation, the consumer_mail channel will be called to send an email notification to the to-do person through the smtp service of the email. Email filtering and email content will be further set later.

If conditional filtering is required, such as not sending email notifications to the "Zhang San" user, it can be achieved through filtering scripts.

return message.person.indexOf("张三")>-1;

The return value true means that it needs to be processed, and false does not need to be processed. The message body comes from different messages according to different time types, and its content and format are different. The specific format content can be viewed through the print statement.

After filtering, customize the content of the message body by creating a loader.

/*
*message 对象是消息体,有脚本执行上下文环境环境自动注入,其中有四个字段
message.title: 标题
message.person: 发送对象
message.type: 消息类型,task_create
message.body: 消息体,类型是task_create的消息中消息体是json格式存储的task(待办)数据
return 返回的message对象
*/
message.title = "您有一份标题为:"+message.body.title+"的待办需要处理。";
message.body = "<a href='http://testing.o2oa.net/x_desktop/work.html?workid="+ message.body.work + "'>您有新的待办需要处理,标题为:" + message.body.title + "</a>";
return message;

Customize email content via loader.

Scenario 2: Write data to the database table after the work is completed

After the workflow is completed, try to write some data into the specified database table

·Prepare a database and create a table with id, title, and total fields defined in the table.

Create a jdbc (database table) channel

We first create a jdbc channel pointing to the workdata table of the testdb database.

Create a loader to set what to write

var id = message.body.work;
var resp = this.applications.getQuery("x_processplatform_assemble_surface", "data/work/"+ id);//根据workid获取到业务数据data
var data = JSON.parse(resp.toString()).data
//修改body属性同步到数据库表中
message.body.id = message.body.id;
message.body.title = data.$work.title;
message.body.total = data.total; 
return message;

Select to add channel consumer_jdbc in type (workCompleted_create)

So far, the configuration of synchronizing data to the database is completed.

Channel Configuration Description

The following describes the 6 non-default channels.

kafka

Push the message to the kafka queue, configuration parameter description:

  • bootstrapServers: server address
  • topic: message category
  • securityProtocol: security protocol
  • saslMechanism: SASL authentication mechanism
  • username: username
  • password: key

activemq

Push the message to the activemq queue, configuration parameter description:

  • url: message queue address
  • queueName: queue name
  • username: username
  • password: password

restful

Call the restful service, configuration parameter description:

  • url: restful calling address
  • method: call methods get, post, put, delete.
  • internal: Whether it is an internal system call, if it is an internal system call, it will be forced to bring the server ID to pass the authority authentication.

mail

Call the smtp server to send mail, configuration parameter description:

  • host: smtp server address
  • port: smtp service port, default 465
  • sslEnable: whether to enable ssl encryption for smtp transmission
  • auth: Whether to enable user authentication
  • from: email sender
  • password: smtp login password

jdbc

Call the database link, write data into the database table, configuration parameter description:

  • driverClass: jdbc driver class
  • url: jdbc address
  • catalog: catalog
  • schema: database
  • table: database table
  • username: username
  • password: password

hadoop

Write data to hadoop file system, configuration parameter description

  • fsDefaultFS: hadoop service address.
  • path: directory to write to.
  • username: Specifies the system account.

(Reposted from the public account: Zhejiang Rand Network)

Guess you like

Origin blog.csdn.net/liyi_hz2008/article/details/126783565