Jump to content

How to publish JSON message from BE5 to EMS


Shanmugam Dhanapal

Recommended Posts

  • 2 months later...

One option is to create a 'Timer Event' with an interval, and add a rule that is triggered by this Timer Event. However, this optioncan't work in a multi-agent Cache OM cluster environment. A more robust solution is to use a rule-based scheduler.

A typical test setup involves the need to publish JMS messgaes to a queue or topic at a specified interval. I do this by creating a scheduler in a startup rule function. So I have a rule function named 'ScheduleJmsPublisher.rulefunction' with the following body:

body {

String sSchedulerName = "SendToJmsScheduler";

String sSchedulerWorkKey = "PositionResponseStatus";

String extId = "12345";

String payload = "{"BookTitle":"Finnegans Wake","BookAuthor":"James Joyce","BookPrice":25.99}";

long iFrequencyMsec = 1000; // every second

 

Cluster.createScheduler(sSchedulerName,iFrequencyMsec,iFrequencyMsec);

Events.SendToJms sendToJms = Events.SendToJms.SendToJms(extId,payload);

Cluster.scheduleRepeatingEvent(sSchedulerName,sSchedulerWorkKey,sendToJms,DateTime.now(),iFrequencyMsec);

}Here, I'm sending a json payload every second to my JMS server. I have an event named 'SendJsonPayload' defined with its default destination set to the queue/topic I want to send to (which is done in my JMS Channel configuration).

After adding this rule function, I open my project's CDD in the CDD Editor in Studio, and go to the 'Agent Classes' tab. Under 'Startup Functions', I add my ScheduleJmsPublisher rule function. So each time the inference agent is started, JMS messages will be published once every second.

Again, this solution only works when you're using Cache object management. You should set the following properties for your cache agents:

be.engine.cluster.scheduler=false

be.engine.cacheServer.channel.disable=trueThis will ensure that the cache agents don't try acting as schedulers, and will not attempt to connect to the JMS destination.

Hope this helps.

-Jim

Link to comment
Share on other sites

  • 1 year later...

As per my understanding,

To Publish a JSON Message. Log in to the management console. Click on the upper left to select the desired region and project. Under Management & Governance, select Simple Message Notification. The SMN console is displayed. In the navigation pane, choose Topic Management > Topics. The Topics page is displayed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...