Page tree
Skip to end of metadata
Go to start of metadata

Package summary

With Cytomine, we can run softwares (see Package Software for more details about softwares and jobs). The middleware packaged is used to transmit data from the core to any other entity whether it is on the same machine (server) or not. When you add a software the core will automatically create the ressources needed to send data related to that specific software.

This package exploits RabbitMQ to handle data between protagonists (core - software). This software implements AMQP, an open standard protocol for message-oriented middleware.


Package main classes


DomainDescriptionMain properties

A domain that supports Advanced Message Queuing Protocol.

String name
String host
String exchange 


Represents a configuration (one parameter) for an AMQP queue implemented with
RabbitMQ. Can be used to declare a queue with default values. 

String name
String defaultValue
Integer index
Boolean isInMap
String Type 

AmqpQueueConfigInstanceDomain used to override a RabbitMQ configuration (i.e. when you want to use something
else other than a default value). 

AmqpQueue queue
AmqpQueueConfig config
String value 




Package description

Package philosophy

Cytomine uses RabbitMQ as a middleware. A few grails plugins that focus on RabbitMQ exist but we wanted more flexibility and we didn't want to be reliant on a developer. For those reasons, the middleware package tries to be independent on the middleware (here RabbitMQ). The middleware could be replaced without much alteration inside the core.


Queue Creation

When we add a software, the service SoftwareService will add an AmqpQueue.

After Add software trigger
def afterAdd(def domain, def response) {
	aclUtilService.addPermission(domain, cytomineService.currentUser.username, BasePermission.ADMINISTRATION)
	// add an AMQP queue with the name of the software (default parameters)
	String queueName = amqpQueueService.queuePrefixSoftware + ((domain as Software).name).capitalize()
	if(!amqpQueueService.checkAmqpQueueDomainExists(queueName)) {
		String exchangeName = amqpQueueService.exchangePrefixSoftware + ((domain as Software).name).capitalize()
		AmqpQueue aq = new AmqpQueue(name: queueName, host: "localhost", exchange: exchangeName) true)
		// Creates the queue on the rabbit server


The queue creation is possible with default values of custom values (using AMQPQueueConfigInstance). These two methods are available inside the AMQPService :

public def createAmqpQueue(AmqpQueue domain);
public def createAmqpQueueDefault(AmqpQueue domain);


You can also easily publish a message (put data on a RabbitMQ queue) with this method :

public def publishMessage(AmqpQueue domain, String messageBody);


The package also provides a utility class to create connections to the middleware, this service is RabbitConnectionService :

public def setRabbitConnection(String host);
public Connection getRabbitConnection(String host);
public def setRabbitChannel(String queueName);
public Channel getRabbitChannel(String queueName);
  • No labels