Giter Club home page Giter Club logo

eventsqueue's Introduction

EventsQueue

Sample of making queue for processing tasks based on InsterSystems Caché %SYSTEM.Event

Example:

/// Starts the queue for processing reports
/// pAgents - number of agents to process the queue, default value = 2
/// pProcess - process tasks that were made before queue has started. 1 - process, 0 - ignore.
ClassMethod StartQueue(pAgents As %Integer = 2, pProcess As %Integer = 0) As %Status
{
	set st = $$$OK
	try {
		$$$TOE(st, ##class(Manager).Start(..#EVENTRESOURCE, 2, $classname(), "ProcessTask"))
		if (pProcess = 1) {
			set id = 0
			while (id < 10) {
				set id = id + 1
				set sent = $system.Event.Signal(..#EVENTRESOURCE, id)
    				if ('sent) $$$ThrowStatus($$$ERROR("Unable to start task processing for id = "_id))
			}
		}
	} catch ex {
		set st = ex.AsStatus()
	}
	quit st
}

/// Stops the queue
ClassMethod StopQueue() As %Status
{
	set st = $$$OK
	try {
		$$$TOE(st, ##class(Manager).Stop(..#EVENTRESOURCE))
	} catch ex {
		set st = ex.AsStatus()
	}
	quit st
}

eventsqueue's People

Contributors

v23ent avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.