---
schema_version: "1"
id: c1aa9c9ef01289f537613beb2d8461a577ca85823c524101488cbb2d873ea0d1
title: WebSockets 管理グループ
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/websockets-connector/latest/websockets-connector-managing-groups.md
canonical_url: https://docs.mulesoft.com/jp/websockets-connector/latest/websockets-connector-managing-groups
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0b9f91edc561a73d87896b1997363e2254f3d60dc881471c56c31c71194e7682
description: MuleSoft Documentation Site
release: "1.0"
latest: true
---
# WebSockets 管理グループ

WebSockets Connector が使用するソケットグループは、WebSockets クライアントが必要に応じてサブスクライブできる文字列 ID です。これは、いわゆるメッセージ分離に便利です。メッセージ分離により、アプリケーションで単一のメッセージを異なる WebSockets クライアントのグループにブロードキャストできます。

グループを利用する方法の例は、ブロードキャスト操作のドキュメントに記載されています。

`<websocket:inbound-listener>`​ トリガーと ​`<websocket:open-outbound-socket>`​ 操作の両方で、デフォルトのグループを指定できます。これは、新規のインバウンドおよびアウトバウンドソケットがすべて自動的にサブスクライブされるグループです。

手動でのサブスクライブまたはグループからのソケットのサブスクライブ解除が必要になるユースケースもあります。たとえば、インバウンド WebSocket が確立されるマルチテナントアプリケーションのユースケースを考えてみましょう。イニシエーターの HTTP 要求には ​`clientId`​ と呼ばれる認証ヘッダーが含まれます。クライアント ID を検証して、クライアントが属する組織を識別する ​`orgId`​ と呼ばれる変数を設定する ​`fetch-client-details`​ と呼ばれるフローをコールします。ソケットがその組織を識別するグループに追加されます。

(組織 ID) にサブスクライブされるグループはランタイムにしか決定できないため、グループサブスクリプションは動的です。

フローの例を次に示します。

```xml
<flow name="onIncomingMessageFlow">
    <websocket:inbound-listener path="/feed" config-ref="ws" />

    <!-- Store relevant information in variables -->
    <set-variable variableName="socketId" value="#[attributes.socketId]" />
    <set-variable variableName="authHeader" value="#[attributes.headers.clientId]" />

    <!-- Validate the auth Header -->
    <flow-ref name="fetch-client-details" />

    <!-- Perform group subscription -->
    <websocket:subscribe-groups
      socketId="#[vars.socketId]"
      groups="#[[vars.orgId]]"
      config-ref="ws" />
</flow>
```

このユースケースの裏側として、グループから動的にサブスクライブ解除する必要もあり、これは ​`<websocket:unsubscribe-groups>`​ 操作を使用して実行できます。

```xml
<websocket:unsubscribe-groups
  socketId="#[vars.socketId]"
  groups="#[[vars.orgId]]"
  config-ref="ws" />
```

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

- [MuleSoft ヘルプセンター](https://help.mulesoft.com)
- [WebSockets Connector の概要](https://docs.mulesoft.com/jp/websockets-connector/latest/)
- [Connector Configuration (コネクタ設定)](https://docs.mulesoft.com/jp/websockets-connector/latest/websockets-connector-config-topics)
- [メッセージング操作](https://docs.mulesoft.com/jp/websockets-connector/latest/websockets-connector-messaging-operations)