# Creating a stream with multiple subjects
js.add_stream(name: "MULTI_FILTER", subjects: ["foo.one.*", "foo.two.*", "foo.three.*"])
# PullSubscriber that takes an array and creates a consumer with multiple filters .
js.pull_subscribe(["foo.one.1", "foo.two.2"], "example")
# PushSubscriber that takes an array and creates a consumer with multiple filters .
js.subscribe(["foo.one.1", "foo.three.3"])
# via JetStream#add_consumer API
consumer = js.add_consumer("MULTI_FILTER", {
name: "my-consumer",
filter_subjects: ["foo.one.*", "foo.two.*"]
})
# Pass nil to both subject and durable consumer name to bind to already created consumer
js.pull_subscribe(nil, nil, name: "my-consumer", stream: "MULTI_FILTER")
# Stream with metadata
stream = js.add_stream({
:name => "WITH_METADATA",
:metadata => {
'foo': 'bar',
'hello': 'world'
}
})
Examples: