def publish(self, topic, schema=None, name=None):
sl = _SourceLocation(_source_info(), '<STR_LIT>')<EOL>schema = streamsx.topology.schema._normalize(schema)<EOL>if schema is not None and self.oport.schema.schema() != schema.schema():<EOL><INDENT>nc = None<EOL>if schema == streamsx.topology.schema.CommonSchema.Json:<EOL><INDENT>schema_change = self.as_json()<EOL><DEDENT>elif schema == streamsx.topology.schema.CommonSchema.String:<EOL><INDENT>schema_change = self.as_string()<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(schema)<EOL><DEDENT>if self._placeable:<EOL><INDENT>self._colocate(schema_change, '<STR_LIT>')<EOL><DEDENT>sp = schema_change.publish(topic, schema=schema, name=name)<EOL>sp._op().sl = sl<EOL>return sp<EOL><DEDENT>_name = self.topology.graph._requested_name(name, action="<STR_LIT>")<EOL>op = self.topology.graph.addOperator("<STR_LIT>", params={'<STR_LIT>': topic}, sl=sl, name=_name, stateful=False)<EOL>op.addInputPort(outputPort=self.oport)<EOL>op._layout_group('<STR_LIT>', name if name else _name)<EOL>sink = Sink(op)<EOL>if self._placeable:<EOL><INDENT>self._colocate(sink, '<STR_LIT>')<EOL><DEDENT>return sink<EOL>
Publish this stream on a topic for other Streams applications to subscribe to.
A Streams application may publish a stream to allow other
Streams applications to subscribe to it. A subscriber
matches a publisher if the topic and schema match.

By default a stream is published using its schema.

A stream of :py:const:`Python objects <streamsx.topology.schema.CommonSchema.Python>` can be subscribed to by other Streams Python applications.

If a stream is published setting `schema` to
:py:const:`~streamsx.topology.schema.CommonSchema.Json`
then it is published as a stream of JSON objects.
Other Streams applications may subscribe to it regardless
of their implementation language.

If a stream is published setting `schema` to
:py:const:`~streamsx.topology.schema.CommonSchema.String`
then it is published as strings
Other Streams applications may subscribe to it regardless
of their implementation language.

Supported values of `schema` are only
:py:const:`~streamsx.topology.schema.CommonSchema.Json`
and
:py:const:`~streamsx.topology.schema.CommonSchema.String`.

Args:
    topic(str): Topic to publish this stream to.
    schema: Schema to publish. Defaults to the schema of this stream.
    name(str): Name of the publish operator, defaults to a generated name.
Returns:
    streamsx.topology.topology.Sink: Stream termination.

.. versionadded:: 1.6.1 `name` parameter.

.. versionchanged:: 1.7
    Now returns a :py:class:`Sink` instance.