---
schema_version: "1"
id: 7c332988c69cb08b59f468e9f15aa77d4eb664c8723479f4161118155382ea40
title: JMS Connector での XA トランザクションの設定
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/jms-connector/1.10/jms-xa-transactions.md
canonical_url: https://docs.mulesoft.com/jp/jms-connector/1.10/jms-xa-transactions
source_site: docs.mulesoft.com
content_type: documentation
content_hash: cec75dc0ef69b8bbfdcae43693e7f2493afe243c0fa62a9bf94d86da1862b68a
description: MuleSoft Documentation Site
release: "1.10"
latest: true
---
# JMS Connector での XA トランザクションの設定

**\[XA Connection Pool (XA 接続プール)\]**​ および ​**\[Transaction Type (トランザクション種別)\]**​ 項目を設定すると、JMS 用 Anypoint Connector (JMS Connector) では拡張アーキテクチャトランザクション (XA トランザクション) を使用するオプションが提供されます。

## [](#始める前に)始める前に

始める前に、[XA Transactions](https://docs.mulesoft.com/mule-runtime/latest/xa-transactions) について理解していることを確認します。

## [](#xa-トランザクションの設定)XA トランザクションの設定

XA トランザクションを設定するには、次の手順に従います。

1. **\[JMS Config (JMS 設定)\]**​ で、​**\[Min pool size (最小プールサイズ)\]**​、​**\[Max pool size (最大プールサイズ)\]**​、および ​**\[Max idle seconds (最大アイドル秒)\]**​ の ​**\[XA Connection Pool (XA 接続プール)\]**​ 項目を設定します。

```xml
 <jms:config name="JMS_Config">
        <jms:active-mq-connection brokerURL="tcp://localhost:61616"
                                  userName="admin"
                                  password="admin">
            <jms:xa-connection-pool minPoolSize="1"
                                    maxPoolSize="10"
                                    maxIdleSeconds="45"/>
        </jms:active-mq-connection>
    </jms:config>
```

1. **JMS Listener**​ ソースの ​**\[XA Transaction (XA トランザクション)\]**​ 項目を ​`[XA]`​ に設定します。

```xml
</flow>
    <flow name="JMS_Listener_Flow">
        <jms:listener
                destination="queue.in"
                config-ref="JMS_Config"
                transactionType="XA"
                transactionalAction="ALWAYS_BEGIN">
            <ee:transform>
                <ee:message>
                    <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
                </ee:message>
            </ee:transform>
        </jms:listener>
        <vm:publish config-ref="VM_Config"
                    queueName="queue"
                    transactionType="XA"
                    transactionalAction="ALWAYS_JOIN"/>
    </flow>
```

**設定 XML**​ エディターウィンドウでは、Mule アプリケーション設定は次のように記述されます。

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
      xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
      xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
      xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <vm:config name="VM_Config">
        <vm:queues>
            <vm:queue queueName="queue"/>
        </vm:queues>
    </vm:config>

    <jms:config name="JMS_Config">
        <jms:active-mq-connection brokerURL="tcp://localhost:61616"
                                  userName="admin"
                                  password="admin">
            <jms:xa-connection-pool minPoolSize="1"
                                    maxPoolSize="10"
                                    maxIdleSeconds="45"/>
        </jms:active-mq-connection>
    </jms:config>

    <http:listener-config name="HTTP_Listener_config">
        <http:listener-connection host="0.0.0.0" port="8081"/>
    </http:listener-config>

    <flow name="JMS_Publish">
        <http:listener config-ref="HTTP_Listener_config"
                       path="/publish"/>
        <jms:publish transactionalAction="ALWAYS_JOIN"
                     destination="queue"/>
    </flow>
    <flow name="JMS_Listener_Flow">
        <jms:listener
                destination="queue.in"
                config-ref="JMS_Config"
                transactionType="XA"
                transactionalAction="ALWAYS_BEGIN">
            <ee:transform>
                <ee:message>
                    <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
                </ee:message>
            </ee:transform>
        </jms:listener>
        <vm:publish config-ref="VM_Config"
                    queueName="queue"
                    transactionType="XA"
                    transactionalAction="ALWAYS_JOIN"/>
    </flow>

    <flow name="VM_Listener_Flow">
        <vm:listener config-ref="VM_Config"
                     transactionalAction="NONE"
                     transactionType="XA"
                     queueName="queue">
        </vm:listener>
        <logger level="INFO"
                message="Message Received from VM Queue: #[payload]"/>
    </flow>
</mule>
```

## [](#関連情報)関連情報

[JMS Connector の例](https://docs.mulesoft.com/jp/jms-connector/1.10/jms-examples)