---
schema_version: "1"
id: 9b6219a955032e83bb3f8e3b2340d65939b6652a929a938c55f6ec9dca99d10f
title: Using Topic Subscriptions
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/jms-connector/1.2/jms-topic-subscription.md
canonical_url: https://docs.mulesoft.com/jms-connector/1.2/jms-topic-subscription
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 94ad0808529202a6b414bb1c1fd3bbc3bde3bc67ec91813eaa1113c21f31cfb8
description: MuleSoft Documentation Site
release: "1.2"
latest: false
---
---
product: JMS Connector
version: 1.2
keywords: jms, connector, consume, source, listener, topic, subscription
---

# Using Topic Subscriptions

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Topics in JMS allow you to configure how the subscription behaves regarding the connection of the
consumer and also how this consumers interact between each other.

Using Mule’s JMS Connector you can handle of the aspects of a Topic subscription using the
'topic-consumer' configuration in both the `consumer` and `listener` operations.

## Registering Durable Subscriptions

Durable subscriptions allows you to receive messages that were published to the topic while the
consumer was offline. Once a durable subscription registered, each time a consumer is available it
will receive all the messages published before the connection was established:

```xml
<jms:consume config-ref="JMS_config" destination="#[vars.destination]">
    <jms:consumer-type>
        <jms:topic-consumer durable="true" subscriptionName="SampleSub"/>
    </jms:consumer-type>
</jms:consume>
```

Then the JMS provider stores the messages sent or published to the topic, as it would store messages
sent to a queue. If this or another application creates a 'topic-consumer' using the same connection
and its client ID, the same topic, and the same subscription name, the subscription is reactivated,
and the JMS provider delivers the messages that were published while the subscriber was inactive.

## Allowing Multiple Consumers on the Same Subscription

In JMS 1.1, a subscription on a topic was not permitted to have more than one consumer at a time,
meaning that the work of processing messages on a topic subscription could not be shared, thereby
limiting the scalability of the application. This restriction has been removed in JMS 2.0 by the
introduction of **shared subscriptions**.

The JMS Connector, **when configured with a JMS 2.0 connection**, allows you to declare any
'topic-consumer' as part of a `shared` subscription:

```xml
<jms:listener config-ref="config" destination="InvoiceEventsTopic">
    <jms:consumer-type>
        <jms:topic-consumer shared="true" subscriptionName="ClusterSubscription"/>
    </jms:consumer-type>
</jms:listener>
```

With this configuration on two different `listener` instances, when a Message is published to the
invoices destination it will be delivered only to one of the listeners and not the other.

## How to Ignore Self Published Messages

There are cases in which you may not want to receive the Messages that were published to a Topic by
the same application. For this cases, you can use the `noLocal` parameter in the 'topic-consumer',
thus preventing the Consumer to receive Messages published to the Topic **by the same Connection**:

```xml
<jms:listener config-ref="config" destination="${notificationsChannel}">
    <jms:consumer-type>
        <jms:topic-consumer noLocal="true"/>
    </jms:consumer-type>
</jms:listener>
```

Consumers configured as `noLocal` **can’t** be part of a `shared` subscription.

## See Also

- [To Listen For New Messages](https://docs.mulesoft.com/jms-connector/1.2/jms-listener)

- [To Consume Messages](https://docs.mulesoft.com/jms-connector/1.2/jms-consume)
