iris-pubsub

Downloads8
Subscribe
0
Bookmark
0
This application is not supported by InterSystems Corporation. Please be notified that you use it at your own responsibility.
Details
Releases
Reviews
Issues
Articles

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.

IPM installation
zpm "install iris-pubsub"
Rating
5 (1)
Category
Integration
Works with
InterSystems IRISInterSystems IRIS for Health
Tags
Info
Version
0.0.1
Last updated
2023-02-23
Repository
Open
Documentation
Open
License
Link