1

私は安らかなWebサービスに取り組んでいます.Webサービスの目的は、入ってくるリクエストに基づいて電子メールを送信することです.

これを実現するために Mule を使用することにしました。リクエスト (POST) を受け取り、それをキューに書き込むミュールでフローを定義しました。次に、このキューから読み取り、sendmail またはその他の Java メール API を使用してメッセージを送信する別のフローがあります。

キューから読み取ってからメールを送信するフローを作成する責任があります。以下は、キューにメッセージを書き込む mule_config.xml フローです。

   <!-- This is the persistent VM connector -->
   <vm:connector name="mailQueueConnector" queueTimeout="1000">
         <vm:queue-profile>
        <file-queue-store />
         </vm:queue-profile>
   </vm:connector>


    <flow name="MailService">
        <https:inbound-endpoint address="https://localhost:71234/message/email"
            method="POST"
            exchange-pattern="request-response"
            contentType="application/xml"/>

        <vm:outbound-endpoint path="mailQueue" connector-ref="mailQueueConnector">
            <message-property-filter pattern="http.status=200" />
            <logger message="INTO mailQueue" level="INFO"/>
        </vm:outbound-endpoint>
        <response>
            <message-property-filter pattern="http.status=200" />
            <script:transformer>
                <script:script engine="groovy">
                    <script:text>
                        import groovy.xml.*
                        def writer = new StringWriter()
                        def xml = new MarkupBuilder(writer)
                        xml.ApiMessage {
                            returnCode("200")
                            reason("Queued Succesfully!!!")
                        }
                        return writer.toString()
                    </script:text>
                </script:script>
            </script:transformer>
        </response>
    </flow>

上記から、インバウンド エンドポイント「https://localhost:71234/message/email」にヒットする POST メール リクエストがキュー「mailQueue」に書き込まれていることがわかります。しかし、私のタスクでは、キューにある電子メール メッセージを読み取り、それを電子メール オブジェクトにシリアル化して、その電子メールを送信するために Java でコーディングできるようにするにはどうすればよいですか? そのための新しいフローを作成する必要があると思います。私は正しいですか?ここで正しい方向に私を向けてください。

4

1 に答える 1

2

以下を使用して新しいフローを作成します。

  • パスvm:inbound-endpointを消費する。mailQueue
  • オプションで、メール本文を準備するためのトランスフォーマー。
  • smtp:outbound-endpointさまざまなプロパティ (宛先、件名など) に MEL 式を使用して、電子メール メッセージを送信する です。

編集 - OP は、HTTP を介して外部からも内部的にもフローにアクセスできるようにする必要があります。それを行うために複合ソースを追加しました:

<flow name="emailer">
    <composite-source>
        <https:inbound-endpoint address="localhost:71234/message/sendEmail"
            method="POST" exchange-pattern="request-response"
            contentType="application/xml" />
        <vm:inbound-endpoint path="mailQueue"
            connector-ref="mailQueueConnector">
    </composite-source>
    <!-- Add transformers here if needed -->
    <smtp:outbound-endpoint ... />
</flow>
于 2012-12-19T23:12:58.013 に答える