SPL File topics.spl

# SPL File `topics.spl`

Toolkits > com.ibm.streamsx.topology 1.15.9 > com.ibm.streamsx.topology.topic > topics.spl

Topic based publish-subscribe model for streams. Supports a microservice architecture for IBM Streams applications where streams are published to topics and can be subscribed to be independent applications. Use of interchange schema types allows applications to be implemented in different langauges, including SPL, Python, Java & Scala.

## Content

Operators
  - Publish: Publish a stream to a topic.
  - Subscribe: Subscribe to topics using a topic filter.
Functions
  - addUDPSubscription(rstring): Take a subscription and modify it to account for parallel regions in the publisher or subscriber.
  - checkTopicFilter(rstring): Check a topic filter is valid.
  - checkTopicName(rstring): Check a topic name is valid.
  - getTopicSubscription(rstring): Get the subscription that matches a topic for topic based subscription.
  - setSubscribeSubscription(rstring): Set a subscription expression adding in UDP channel based matching if the subscriber is in a parallel region.

## Composites

## composite Publish(input In)

Publish a stream to a topic. Allows other IBM Streams applications to subscribe to the input stream, including those written in different languages. See namespace:com.ibm.streamsx.topology.topic for details.

## Parameters

- topic: Topic to publish stream to.
- allowFilter: True if filters can be pushed from subscribing SPL applications. Optional, defaults to `false`.

## Input Ports

- In: Stream to be published as a topic.

## composite Subscribe(output Topic)

Subscribe to topics using a topic filter. Generates a stream that is subscribed, through IBM Streams dynamic connections, to all streams published to topics that match the topic filter `topic` and are an exact stream type match to `streamType`.

See namespace:com.ibm.streamsx.topology.topic for details.

## Parameters

- topic: Topic filter to subscribe to.
- streamType: Type of output stream `Topic`.
- connect: Connection mode between subscriber and publishers. Can be set to Direct or Buffered. The default is `Direct`. See Connection mode.
- bufferFullPolicy: Buffer policy when the buffer is full. Ignored when `connect` is set to `Direct`.
- bufferCapacity: Capacity of the buffer in number of tuples. Ignored when `connect` is set to `Direct`.

## Output Ports

- Topic: Subscription to `topic`.

## Functions

## rstring getTopicSubscription(rstring topic)

Get the subscription that matches a topic for topic based subscription.

This is a low-level function that allows applications to build custom composites with functionality similar to Subscribe. The preference should be to use Subscribe where possible.

## Parameters

- topic: Topic to subscribe to.

## Returns

- `rstring`

## rstring addUDPSubscription(rstring subscription)

Take a subscription and modify it to account for parallel regions in the publisher or subscriber.

This is a low-level function that allows applications to build custom composites with functionality similar to Subscribe or FilteredSubscribe. The preference should be to use Subscribe or FilteredSubscribe where possible.

## Parameters

- subscription: Base subscription.

## Returns

- `rstring`

## int32 setSubscribeSubscription(rstring subscription)

Set a subscription expression adding in UDP channel based matching if the subscriber is in a parallel region.

## Parameters

- subscription: Subscription to be set on input port connected to `Import` operator.

## Returns

- `int32`

## boolean checkTopicName(rstring topic)

Check a topic name is valid.

## Parameters

- topic

## Returns

- `boolean`

## boolean checkTopicFilter(rstring topic)

Check a topic filter is valid.

## Parameters

- topic

## Returns

- `boolean`