Home Applications iris-pubsub

iris-pubsub

InterSystems does not provide technical support for this project. Please contact its developer for the technical assistance.
5
1 reviews
0
Awards
236
Views
4
IPM installs
1
0
Details
Releases (1)
Reviews (1)
Issues
Articles (1)
Simple local Publisher-Subscriber utility for InterSystems IRIS

What's new in this version

Initial release

Simple local Publisher-Subscriber utility for InterSystems IRIS.

QuickStart

  • Run sample container
docker-compose up -d
  • PubSub uses dc.PubSub.Interop.Production. It’s empty.
  • Create some partitions. This is only needed the first time. Check the production again.
do ##class(dc.PubSub.API).AddPartitions(3)
  • Create a topic:
    • You will create a topic called simple/topic.
    • Optionally, you can add a PartitionKey in your topic. This allows you to define which field, in a message published in your topic, will be used to determine the partition that will handle the message.
    • All messages in same partition are processed in order.
set topic = ##class(dc.PubSub.API).CreateTopic("simple/topic", { "PartitionKey": "patientId" })
  • Create some subscribers to your topic.
  • These subscribers are class methods that will be called each time a message is published in the topic you created.
  • The endpoint to specify your subscriber goes like this: <namespace>:<package>:<classmethod>
do ##class(dc.PubSub.API).CreateSubscription("simple/topic", { "Protocol": "ClassMethod", "Endpoint": "USER:dc.PubSub.Test.Simple:Subscriber"})
do ##class(dc.PubSub.API).CreateSubscription("simple/topic", { "Protocol": "ClassMethod", "Endpoint": "USER:dc.PubSub.Test.Simple:Sub2"})
  • Publish some messages to your topic
do ##class(dc.PubSub.API).Publish("simple/topic", {"patientId": "HA98744455", "data": "dummy" } )
do ##class(dc.PubSub.API).Publish("simple/topic", {"patientId": "12TFFFHM88", "data": "dummy999" } )
  • Check messages in your production

  • Also, check included ^zlog global:

zw ^zlog
^zlog=4
^zlog(1)="[dc.PubSub.Test.Simple:Subscriber] Received: {""patientId"":""HA98744455"",""data"":""dummy""}"
^zlog(2)="[dc.PubSub.Test.Simple:Sub2] Received: {""patientId"":""HA98744455"",""data"":""dummy""}"
^zlog(3)="[dc.PubSub.Test.Simple:Subscriber] Received: {""patientId"":""12TFFFHM88"",""data"":""dummy999""}"
^zlog(4)="[dc.PubSub.Test.Simple:Sub2] Received: {""patientId"":""12TFFFHM88"",""data"":""dummy999""}"

Installation

  1. Install IPM package manager if you don’t have already done it.
  2. Create a new namespace (e.g. TEST). iris-pubsub needs to be installed in a new namespace because it runs its own interoperability production.
  3. Switch to your new namespace and run:
TEST> zpm
zpm:TEST> install iris-pubsub
  1. Setup how many partitions (Business Service - Business Operation) you want to run:
TEST> do ##class(dc.PubSub.API).AddPartitions(3)

And you are done, check the QuickStart section for some examples.

Made with
Install
zpm install iris-pubsub download archive
Version
0.0.120 Feb, 2023
Category
Integration
Works with
InterSystems IRISInterSystems IRIS for Health
First published
20 Feb, 2023
Last edited
23 Feb, 2023
Last checked by moderator
31 Jan, 2025Works