Streams

A stream is a method of topic partitioning used by WebSphere MQ Publish/Subscribe applications. Sets of related topics are grouped together into separate streams.

By using streams, different security controls can be applied to different groups of topics, and the publishing workload of the broker can be better balanced.

Although WebSphere Message Broker provides other ways for an application to achieve both of these behaviors, the concept of streams is supported for compatibility with MQRFH applications.

WebSphere Message Broker allows MQRFH client applications to specify an MQPSStreamName command parameter in their subscriptions and publications. However, the stream name is used only to modify the topic to preserve the partitioning characteristic of WebSphere MQ Publish/Subscribe.

If the name of a stream associated with a message is not SYSTEM.BROKER.DEFAULT.STREAM, the message is processed as if the topic, or topics, mentioned within the message had been prefixed with the string "$SYS/STREAM/<streamname>/". For example, a subscription to Topic1 that specifies a stream name of StreamX is processed as if the subscription had been made to topic "$SYS/STREAM/StreamX/Topic1".

MQRFH2 publishing and subscribing applications can also target stream-related topics, even though they themselves cannot specify a stream name in the messages they send to the WebSphere Message Broker broker. To do this, they must prefix the topics with the appropriate stream prefix.

For example, an MQRFH2 subscriber must specify topic "$SYS/STREAM/STOCK.STREAM/IBM/Latest" to subscribe to topic "IBM/Latest" that is published on stream STOCK.STREAM within the WebSphere MQ Publish/Subscribe network.

WebSphere MQ Publish/Subscribe allows a stream-related publication to be sent only to a queue having the same name as the stream. However, WebSphere Message Broker allows publishing clients to send their publications to any input queue in a message flow. MQRFH applications choosing explicitly to specify a stream name parameter within a publication can send it to any publication queue being serviced by the WebSphere Message Broker broker. The name of the queue does not have to be the same as the name of the stream. However, this behavior might affect the order in which publications are received. Consider whether this is important for your applications.

Each Publication node has an Implicit Stream Naming property that defaults to true. This default option results in behavior that is identical to that in WebSphere MQ Publish/Subscribe when an MQRFH publication does not contain an explicit stream name. If this property is false, and the publication contains no explicit stream name, SYSTEM.BROKER.DEFAULT.STREAM is assumed.

The options that are available to both MQRFH and MQRFH2 client applications that publish messages are shown in the following table; the table shows the options for both the default stream and an example stream name of StreamX.

  MQRFH publisher   MQRFH2 publisher  
  default stream StreamX default stream StreamX
MQRFH subscriber S1,P1 S2,P2 S1,P3 S2,P4
MQRFH2 subscriber S3,P1 S4,P2 S3,P3 S4,P4

Subscriber notes

S1
Subscriber subscribes either without a stream name or with stream name "SYSTEM.BROKER.DEFAULT.STREAM".
S2
Subscriber subscribes with stream name "StreamX".
S3
Subscriber subscribes on topic without adding "$SYS/STREAM/<streamname>/".
S4
Subscriber subscribes prefixes topic with "$SYS/STREAM/StreamX/".

Publisher notes

P1
Publisher publishes on any queue specifying stream name "SYSTEM.BROKER.DEFAULT.STREAM", or publishes without specifying a stream name on any queue with the Implicit Stream Naming property set to false.
P2
Publisher publishes on any queue specifying stream name "StreamX", or publishes without specifying a stream name on queue "StreamX" with the Implicit Stream Naming property set to true.
P3
Publisher publishes on any queue without adding the prefix "$SYS/STREAM/<Stream>/" to the topic.
P4
Publisher publishes on any queue and adds the prefix "$SYS/STREAM/StreamX/" to the topic.
Note: The "$SYS/STREAM/<streamname>/" prefix is removed from all topics in an MQRFH2 publication when it is delivered to an MQRFH subscriber.

Streams and neighboring brokers

In a WebSphere MQ Publish/Subscribe network, a broker does not have to support the same set of streams as its neighbors. If a broker does not support a stream that is supported by one of its neighboring brokers, publications associated with that stream are not available to clients at that broker.

When an WebSphere Message Broker broker joins the network, it supports all the streams of its neighboring WebSphere MQ Publish/Subscribe brokers. This means that clients of the WebSphere Message Broker broker can target publications for any stream supported by any of its WebSphere MQ Publish/Subscribe neighbors.

However, to make these publications available, you must define the stream queues, and define and deploy the message flows that support them, to the WebSphere Message Broker broker.

The effects of adding an WebSphere Message Broker broker into a multi-stream WebSphere MQ Publish/Subscribe environment are illustrated in the following figure. The WebSphere Message Broker broker, NEWBROKER, has been used to join WebSphere MQ Publish/Subscribe brokers, BROKERA, and BROKERB.

A heterogeneous network


A heterogeneous network. This figure shows a <ph conref='edvent.dita#edvent/mqsi'></ph> broker, NEWBROKER, placed between two <ph conref='edvent.dita#edvent/sdk'></ph> brokers, BROKERA, and BROKERB. It also lists the streams associated with each of the two <ph conref='edvent.dita#edvent/sdk'></ph> brokers.

The default stream queue SYSTEM.BROKER.DEFAULT.STREAM is always supported by every broker in an WebSphere MQ Publish/Subscribe network, and must be defined at every WebSphere Message Broker broker in a heterogeneous network. At each broker, you must define and deploy a message flow to service this queue.

When a WebSphere Message Broker broker is integrated into an WebSphere MQ Publish/Subscribe network, and links two or more WebSphere MQ Publish/Subscribe brokers that share common streams, you must define the common stream queues, and define and deploy the message flows that service them, to the WebSphere Message Broker broker.

For example, the WebSphere Message Broker broker NEWBROKER must have a stream queue defined for BULLETIN.STREAM. It must also have a message flow defined and deployed to provide a publication service for that queue.

You need to define stream queues and associated message flows to the WebSphere Message Broker broker for other streams shown in the figure only if one of its WebSphere MQ Publish/Subscribe neighbors can send a message to one of these queues. A message is sent if one of the following events occurs:
  1. A subscription to a publication on one of these streams is registered by a client of the WebSphere Message Broker broker.
  2. A DeletePublication command for the stream is issued by a client anywhere within the broker network.
If you are unsure about whether the above cases might occur, create stream queues and message flows in the WebSphere Message Broker broker for every stream that is supported by an WebSphere MQ Publish/Subscribe neighbor. If you do not do this, the following might happen:
  • Messages sent from WebSphere MQ Publish/Subscribe brokers are put on the dead-letter queue (DLQ) of the WebSphere Message Broker broker if the stream queue does not exist on that broker.
  • Messages build up on stream queues on the WebSphere Message Broker broker if the stream queue exists but no message flow is deployed to service it.

Streams and migration

When an WebSphere MQ Publish/Subscribe broker is migrated to an WebSphere Message Broker broker (using the migmqbrk command), the streams supported at the time of the migration are replicated exactly in the WebSphere Message Broker broker. No changes can be made subsequently; that is, no streams can be added to, or removed from, this replicated set. The migration is not complete until you have created and deployed message flows that process all these streams.

Related tasks
Subscribing
Related reference
MQRFH2 header