0

作为整个项目的一部分,我需要创建一个 Message-Broker 应用程序,它接受 XML 格式的数据并生成电子邮件。

我创建了一个消息流,如下所示

“MQ 输入 - 计算 - 电子邮件输出”

请帮我在xml文件中写什么来生成上述流程。

esql 文件包含以下代码: CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN CALL CopyMessageHeaders();

    -- Add recipient information to the EmailOutputHeader
    SET OutputRoot.EmailOutputHeader.To = '<recipient email address>';
    SET OutputRoot.EmailOutputHeader.Cc = '<recipient email address>';
    SET OutputRoot.EmailOutputHeader.Bcc = '<recipient email address>';

    -- Add sender information to EmailOutputHeader
    SET OutputRoot.EmailOutputHeader.From = '<sender email address>';
    SET OutputRoot.EmailOutputHeader."Reply-To" = '<reply email address>';

    -- Add subject to EmailOutputHeader
    SET OutputRoot.EmailOutputHeader.Subject = 'Replaced by ESQL compute node.';

    -- Add SMTP server information to the LocalEnvironment
    SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';

    -- Create a new message body, which will be sent as the main text of the email.
    SET OutputRoot.BLOB.BLOB = CAST('This is the new text for the body of the email.' AS BLOB CCSID 1208);          

    RETURN TRUE; 
END;
4

2 回答 2

0

您可以使用 XPATH、InputRoot.XMLNC、Environment 或 LocalEnvironment 传递值。如果我们满足您的要求,那么消息似乎来自您正在使用 XMLNSC 解析器的 MQInput 节点。

  -- Add recipient information to the EmailOutputHeader
  SET OutputRoot.EmailOutputHeader.To = InputRoot.XMLNSC.EmailData.To;

  -- Add sender information to EmailOutputHeader
  SET OutputRoot.EmailOutputHeader.From = InputRoot.XMLNSC.EmailData.From;

  -- Add subject to EmailOutputHeader
  SET OutputRoot.EmailOutputHeader.Subject = InputRoot.XMLNSC.EmailData.Subject;

  -- Add SMTP server information to the LocalEnvironment
  -- You can Add Smtp Server From Configuration in Your Broker Administration side as Configurable Service
  SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';

  -- Create a new message body, which will be sent as the main text of the email.
  SET OutputRoot.BLOB.BLOB = CAST(InputRoot.EmailData.Body AS BLOB CCSID 1208);  

对于测试,在测试客户端中键入此 XML 文件

<EmailData>
    <To>recieverEmail@example.com</To>
    <From>fooSenderEmail@example.com</From>
    <Subject>Testing Email App</Subject>
    <Body><![CDATA[<h1>Testing Email Data</h1><br/><hr /><br/><h6>Testing Email</h6></hr />]]></Body>
</EmailData>
于 2014-10-20T10:40:50.353 回答
0

我完全不知道你在说什么 xml 文件。通过添加和连接您指定的三个节点,在消息代理工具包中布置 msg 流。然后将您的代码添加到计算节点。

于 2014-01-10T11:59:10.503 回答