Flex Gateway新着情報
Governance新着情報
Monitoring API ManagerMicrosoft Service Bus 用 Anypoint Connector (Microsoft Service Bus Connector) を使用すると、オンプレミスの Windows Service Bus とのメッセージインテグレーションが可能になります。このコネクタは、Advanced Message Queuing Protocol (AMQP) 1.0 を使用して、キューおよびトピックとの通信をサポートします。さらに、組み込みの管理 API を使用した Service Bus オブジェクトの動的な検出とプロビジョニングが可能です。
Microsoft Azure でメッセージインテグレーションのシナリオを実装するには、このコネクタの代わりに Microsoft Azure Service Bus Connector を使用します。
リリースノート: 『Microsoft Service Bus Connector リリースノート』
Exchange: Microsoft Service Bus Connector
このコネクタでは、Microsoft Windows Service Bus オンプレミスソリューションへの接続のみがサポートされます。Microsoft Azure Service Bus に接続するには、 Azure Service Bus 用 Anypoint Connector |
このコネクタを使用するには、Microsoft Service Bus、Mule Runtime Engine (Mule)、Anypoint Connector、Anypoint Studio、Mule の概念、Mule フローの要素、グローバル要素に精通している必要があります。
対象リソースへの接続をテストするには、次のいずれかのログイン情報の種類が必要です。
Windows ログイン情報の種類
SAS (共有アクセス署名) - 廃止
ユーザー名とパスワード - 廃止
ソフトウェアの要件および互換性情報については、「コネクタリリースノート」を参照してください。
Apache Maven でこのコネクタを使用するには、 Anypoint Exchange の [Dependency Snippets (連動関係スニペット)] リンクをクリックしてください。
このコネクタでは、オンプレミスの Microsoft Windows Service Bus がサポートされています。
<dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule-microsoft-service-bus-connector</artifactId>
<version>x.x.x</version>
<classifier>mule-plugin</classifier>
</dependency>
xml
コネクタの version
が、使用しているバージョンと一致していることを確認します。
最新の pom.xml
ファイル情報を取得する手順は、次のとおりです。
Anypoint Exchange に移動します。
Exchange で、[Login (ログイン)] をクリックし、Anypoint Platform のユーザー名とパスワードを指定します。
Exchange で、「SAP S/4HANA OData
」を検索します。
[Dependency Snippets (連動関係スニペット)] をクリックします。
Studio で Mule プロジェクトを作成します。
[Mule Palette (Mule パレット)] ビューで、[(X) Search in Exchange ((X) Exchange 内を検索)] をクリックします。
[Add Modules to Project (モジュールをプロジェクトに追加)] で、検索項目に「service bus
」と入力します。
[Available modules (使用可能なモジュール)] で、このコネクタの名前をクリックします。
[Add (追加)] をクリックします。
[Finish (完了)] をクリックします。
コネクタの操作を Studio キャンバスにドラッグします。
コネクタのグローバル要素を設定します。
このユースケースでは、特定の名前空間内の既存のキューのリストを取得します。リストは JSON 形式で返されます。
Studio で新しい Mule アプリケーションを作成し、新しいフローのソースとして [HTTP] > [Listener (リスナー)] を選択します。
新しい HTTP リスナー設定のグローバル要素を追加します。
[Host (ホスト)] パラメーターと [Port (ポート)] パラメーターに次の値を指定します。
パラメーター | 値 |
---|---|
Host (ホスト) |
0.0.0.0 |
Port (ポート) |
8081 |
[Save (保存)] をクリックします。
新しいグローバル設定を HTTP リスナーに割り当てます。
HTTP リスナーのパスに /servicebus
という値を設定します。
新しい Service Bus コンポーネントの操作をフローにドラッグします。
Service Bus Connector のグローバル要素に環境値を設定します。
コネクタの前に [Transform Message (メッセージの変換)] を追加し、次のような出力を追加します。
%dw 2.0
output application/json
---
payload
dataweave
プロジェクトを保存し、Mule アプリケーションとして実行します。
アプリケーションをテストするには、http://127.0.0.1:8081/servicebus
に移動します。
XML フロー:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:servicebus="http://www.mulesoft.org/schema/mule/servicebus"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/servicebus
http://www.mulesoft.org/schema/mule/servicebus/current/mule-servicebus.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<configuration-properties file="mule-app.properties" />
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<servicebus:config name="Servicebus_Config" doc:name="Servicebus Config" >
<servicebus:windows-connection
namespace="${config.namespace}"
username="${config.username}"
password="${config.password}"
fqdn="${config.fqdn}" />
</servicebus:config>
<flow name="servicebusFlow">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
path="/servicebus"/>
<servicebus:queues-list doc:name="Queues list" config-ref="Servicebus_Config"/>
<ee:transform doc:name="Object to JSON">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
xml
接続性テストの実行中または Mule アプリケーションの開始中に次のいずれかのエラーが発生した場合、トラストストアを非セキュアモードで設定する必要があります。
SSL certificate error
General SSLEngine problem
トラストストアを非セキュアモードで設定する手順は、次のとおりです。
グローバル要素設定の [Security (セキュリティ)] タブに移動します。
[Security (セキュリティ)] 項目で [Edit inline (インライン編集)] を選択します。
[Trust Store Configuration (トラストストア設定)] セクションで [Insecure (非セキュア)] チェックボックスを選択します。
[OK] をクリックします。
1 番目の項目は [Edit inline (インライン編集)] を選択する場所を示し、2 番目の項目は [Insecure (非セキュア)] チェックボックスを選択する場所を示しています。
詳細は、「失敗した接続性テスト」を参照してください。
Microsoft Service Bus Connector を使用してメッセージを送受信する場合、認証は AMQP を使用して実行されます。
REST 管理 API の場合、認証スキームは Microsoft Service Bus バージョンによって異なります。Windows Service Bus では、OAuth が使用されます。
Windows Service Bus は、自己署名 SSL 証明書を使用し、AMQP および HTTPS を使用して通信のセキュリティを確保します。この証明書が、Mule を実行するボックスのローカルにインポートされていない場合は、[Ignore SSL warning check (SSL 警告チェックを無視)] が有効になっていない限り、コネクタは実行されません。 |
SSL チェックを有効にするには、次の手順に従って証明書をインポートします。
PowerShell cmdlet Get-SBAutoGeneratedCA を使用して、Windows Service Bus を実行するマシンのローカルに証明書をダウンロードします。
この例では、証明書ファイルは %temp%\AutoGeneratedCA.cer
にエクスポートされます。
システム管理者として実行し、%programfiles%\Java\jre7
に移動します。
Keytool.exe
で証明書のインポートを行うには、システム管理者として実行している必要があります。
bin\keytool.exe
ツールと lib\security\cacerts
が存在することを確認します。
次のコマンドを入力します。
bin\keytool.exe –list –keystore lib\security\cacerts
次のコマンドを実行して、自動生成された Service Bus 証明書をインポートします: + bin\keytool.exe –importcert –alias AppServerGeneratedSBCA –file %temp%\AutoGeneratedCA.cer –keystore lib\security\cacerts –v
要求されたらパスワードを入力します (デフォルトは「changeit」です)。
証明書を信用するかどうかを尋ねられたら、Y
(はい) と入力します。
リソースレベルの権限があるセキュリティポリシーを使用しているなど、リソースへのアクセスを制限している場合、コネクタは開始時に接続性テストを実行できません。これは、shared access key
に適用されているカスタムポリシーによって禁止されている可能性がある名前空間のルートレベルが接続性テストの対象になっているためです。このようなシナリオでは、この目的のために使用できる設定オプションで接続性テストをスキップします。スキップしない場合、コネクタは開始できません。
コネクタを使用するときに要求と応答を記録するには、Mule アプリケーションの log4j2.xml
設定ファイルの Loggers
要素に次の行を追加して、ロガーを設定します。
<AsyncLogger name="org.springframework.web.client"
level="DEBUG"/>
xml
次の例は、AsyncLogger
行が追加された Loggers
要素を示しています。
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<AsyncLogger name="org.springframework.web.client" level="DEBUG" additivity="false">
<appender-ref ref="Console" level="debug"/>
</AsyncLogger>
</Loggers>
</Configuration>
xml
アプリケーションログは次の方法で表示できます。
アプリケーションを Anypoint Platform から実行している場合、出力は Anypoint Studio のコンソールウィンドウに表示される。
コマンドラインから Mule を使用してアプリケーションを実行している場合、アプリケーションログは OS コンソールに表示される。
アプリケーションのログファイル (log4j2.xml
) でログファイルパスがカスタマイズされていない場合、次のデフォルトの場所でアプリケーションログを表示することもできます。
MULE_HOME/logs/<app-name>.log
アプリケーションログについての詳細は、「ログの設定」を参照してください。
このユースケースには、トピックおよびキューのメッセージを送受信する次のフローが含まれます。
load-http-form-flow
メッセージのパラメーターを入力するための Web フォームを提供します。
topic-endpoint-flow
load-http-form-flow
を使用してメッセージを受信し、各メッセージをペイロードとして保存して、Java オブジェクトに変換し、宛先トピックに送信します。
queue-endpoint-flow
load-http-form-flow
を使用してメッセージを受信し、各メッセージをペイロードとして保存して、Java オブジェクトに変換し、宛先キューに送信します。
queue-receive-flow
特定のキューからのメッセージをリスンし、受信して、記録します。
topic-receive-flow
特定のトピックからのメッセージをリスンし、受信して、記録します。
このフローの XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:servicebus="http://www.mulesoft.org/schema/mule/servicebus"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/servicebus
http://www.mulesoft.org/schema/mule/servicebus/current/mule-servicebus.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<configuration-properties file="mule-app.properties" doc:name="Configuration properties"/>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<servicebus:config name="Microsoft_Service_Bus_Config" doc:name="Microsoft Service Bus Config">
<servicebus:windows-connection
namespace="${windows.namespace}"
username="${windows.username}"
password="${windows.password}"
fqdn="${windows.fqdn}"
port="${windows.port}"/>
</servicebus:config>
<flow name="load-http-form-flow">
<http:listener doc:name="Root Endpoint" config-ref="HTTP_Listener_config"
path="/" />
<parse-template doc:name="Web Form" location="form.html" />
</flow>
<flow name="queue-endpoint-flow">
<http:listener doc:name="Queue Endpoint" config-ref="HTTP_Listener_config"
path="/pushMessageQueue" />
<ee:transform doc:name="Convert Payload to Java Object">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/java
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<servicebus:queue-send doc:name="Queue send" config-ref="Microsoft_Service_Bus_Config"
destinationQueue="#[payload.queue]">
<servicebus:message >
<servicebus:body ><![CDATA[#[payload.message]]]></servicebus:body>
</servicebus:message>
</servicebus:queue-send>
</flow>
<flow name="topic-endpoint-flow">
<http:listener doc:name="Topic Endpoint" config-ref="HTTP_Listener_config"
path="/pushMessageTopic"/>
<ee:transform doc:name="Convert Payload to Java Object">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<servicebus:topic-send doc:name="Topic send" config-ref="Microsoft_Service_Bus_Config"
destinationTopic="#[payload.topic]"
transactionalAction="NOT_SUPPORTED"
sendCorrelationId="AUTO">
<servicebus:message >
<servicebus:body ><![CDATA[#[payload.message]]]></servicebus:body>
</servicebus:message>
</servicebus:topic-send>
</flow>
<flow name="queue-receive-flow">
<servicebus:listener
sourceType="Queue"
destination="${queue.name}"
doc:name="Queue receive"
config-ref="Microsoft_Service_Bus_Config"
ackMode="AUTO" subscription="NONE"
numberOfConsumers="1"/>
<logger level="INFO" doc:name="Log the message" message="#[payload]"/>
</flow>
<flow name="topic-receive-flow">
<servicebus:listener sourceType="Topic" doc:name="Topic receive"
config-ref="Microsoft_Service_Bus_Config"
ackMode="AUTO" destination="${topic.name}"
subscription="${subscription.name}"/>
<logger level="INFO" doc:name="Log the message" message="#[payload]"/>
</flow>
</mule>
xml
このユースケースには、トピック、サブスクリプション、およびルールを作成するフローが含まれます。
service-bus-management-demoFlow
次の手順に従って、トピックを作成します。
指定されたとおりにトピックの説明を作成してペイロードとして保存します。
前のステップで保存した設定と、変数 topic.name
から取得したトピックの名前空間を使用してトピックを作成します。
新しく作成したトピックを JSON オブジェクトに変換します。
JSON オブジェクトを記録します。
service-bus-management-demoFlow1
次の手順に従って、サブスクリプションを作成します。
指定されたとおりにサブスクリプションの説明を作成してペイロードとして保存します。
前のステップで保存した設定、変数 subscription.name
から取得したサブスクリプション名、および変数 topic.name
から取得したトピック名を使用してサブスクリプションを作成します。
新しく作成したサブスクリプションを JSON オブジェクトに変換します。
JSON オブジェクトを記録します。
service-bus-management-demoFlow2
次の手順に従って、ルールを作成します。
指定された設定でルールを作成してペイロードとして保存します。
前のステップで保存した設定、変数 rule.name
から取得したルール名、変数 subscription.name
から取得したサブスクリプション名、および変数 topic.name
から取得したトピック名を使用してルールを作成します。
新しく作成したルールを JSON オブジェクトに変換します。
JSON オブジェクトを記録します。
XML フロー:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:servicebus="http://www.mulesoft.org/schema/mule/servicebus"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/servicebus
http://www.mulesoft.org/schema/mule/servicebus/current/mule-servicebus.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<configuration-properties file="mule-app.properties"
doc:name="Configuration properties"/>
<http:listener-config name="HTTP_Listener_config"
doc:name="HTTP Listener config">
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<servicebus:config name="Microsoft_Service_Bus_Config" doc:name="Microsoft Service Bus Config">
<servicebus:windows-connection
namespace="${windows.namespace}"
username="${windows.username}"
password="${windows.password}"
fqdn="${windows.fqdn}"
port="${windows.port}"/>
</servicebus:config>
<flow name="service-bus-management-demoFlow">
<http:listener doc:name="Topic Create Endpoint"
config-ref="HTTP_Listener_config"
path="/topic"/>
<ee:transform doc:name="Set ServiceBusTopicDescription">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
defaultMessageTimeToLive: "P10675199DT2H48M5.4775807S",
duplicateDetectionHistoryTimeWindow: "PT10M",
enableBatchedOperations: false,
maxSizeInMegabytes: 1024,
requiresDuplicateDetection: false,
sizeInBytes: null
} as Object {
class : "com.mulesoft.connectors.microsoft.servicebus.extension.api.entity.ServiceBusTopicDescription"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<servicebus:topic-create doc:name="Topic create"
config-ref="Microsoft_Service_Bus_Config"
topicPath="${topic.name}">
</servicebus:topic-create>
<ee:transform doc:name="Object to Json">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
author: payload.author,
id: payload.id,
title: payload.title
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>
<flow name="service-bus-management-demoFlow1">
<http:listener doc:name="Subscription Create Endpoint"
config-ref="HTTP_Listener_config"
path="/subscription"/>
<ee:transform doc:name="Set ServiceBusSubscriptionDescription">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
lockDuration: "PT4M",
requiresSession: false,
deadLetteringOnMessageExpiration: false,
deadLetteringOnFilterEvaluationExceptions: null,
enableBatchedOperations: false,
defaultMessageTimeToLive: "P10675199DT2H48M5.4775807S",
maxDeliveryCount: null
} as Object {
class : "com.mulesoft.connectors.microsoft.servicebus.extension.api.entity.ServiceBusSubscriptionDescription"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<servicebus:subscription-create
topicPath="${topic.name}"
doc:name="Subscription create"
config-ref="Microsoft_Service_Bus_Config"
subscriptionPath="${subscription.name}"/>
<ee:transform doc:name="Object to Json">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
linik: payload.link,
id: payload.id,
title: payload.title
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>
<flow name="service-bus-management-demoFlow2">
<http:listener doc:name="Rule Create Endpoint"
config-ref="HTTP_Listener_config"
path="/rule"/>
<ee:transform doc:name="Set ServiceBusRuleDescription">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
action: {
sqlExpression: "set MyProperty2 = 'ABC'",
"type": "SqlRuleAction"
},
filter: {
correlationId: null,
sqlExpression: "property1 = 'ok'",
"type": "SqlFilter"
}
} as Object {
class : "com.mulesoft.connectors.microsoft.servicebus.extension.api.entity.ServiceBusRuleDescription"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<servicebus:rule-create topicPath="${topic.name}" doc:name="Rule create"
config-ref="Microsoft_Service_Bus_Config" rulePath="${rule.name}"
subscriptionPath="${subscription.name}"/>
<ee:transform doc:name="Object to Json">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
link: payload.link,
id: payload.id,
title: payload.title
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>
</mule>
xml