/
Message Broker

Message Broker

The Proposal Backend

This page lists the events that are being sent over the message broker and too which queues as well as which events the system is looking out for.

RabbitMQ supports 2 main types of message queues: queues and exchanges. Broadly speaking queues are just what they seem, you can post a message to it and some consumer can take that message out it is important to note if you have multiple consumers on the same queue in theory only one of them will read the message . Exchanges (well a least the one we are using are there different types) are set up so multiple consumers can receives the same message. To do this the consumer sets up a queue and binds it to a exchange. When the producer sends to a message to the exchange it will then send the message on to any bound queues therefore ensuring all consumers get the message.

For a more in-depth look at RabbitMQ they provide a few nice tutorials: RabbitMQ Tutorials | RabbitMQ

Within messageBroker.ts we define a default exchange

export const EXCHANGE_NAME = process.env.CORE_EXCHANGE_NAME || 'user_office_backend.fanout';

But this can be overwritten if needed:

await rabbitMQ.sendMessageToExchange( event.exchange || EXCHANGE_NAME, event.type, jsonMessage );

We have a general type ProposalMessageData which is sent over most events:

const messageData: ProposalMessageData = { proposalPk: proposal.primaryKey, shortCode: proposal.proposalId, instrument: instrument, title: proposal.title, abstract: proposal.abstract, callId: call.id, allocatedTime: proposalAllocatedTime, instrumentId: instrument?.id, members: proposalUsersWithInstitution.map( (proposalUserWithInstitution) => ({ firstName: proposalUserWithInstitution.user.firstname, lastName: proposalUserWithInstitution.user.lastname, email: proposalUserWithInstitution.user.email, id: proposalUserWithInstitution.user.id.toString(), oidcSub: proposalUserWithInstitution.user.oidcSub, oauthIssuer: proposalUserWithInstitution.user.oauthIssuer, institution: proposalUserWithInstitution.institution, country: proposalUserWithInstitution.country, }) ), newStatus: proposalStatus?.shortCode, submitted: proposal.submitted, };

For details of specific events and what data they are sending please look at the message broker itself:

https://github.com/UserOfficeProject/user-office-core/blob/30b5dc11b105cc863394456f246706c046dc7705/apps/backend/src/eventHandlers/messageBroker.ts#L208C1-L208C1

The list of events being sent as of 30/11/2023

Event.PROPOSAL_CREATED Event.PROPOSAL_UPDATED Event.PROPOSAL_SUBMITTED Event.PROPOSAL_DELETED Event.PROPOSAL_STATUS_ACTION_EXECUTED: Event.INSTRUMENT_CREATED Event.INSTRUMENT_UPDATED Event.INSTRUMENT_DELETED Event.TOPIC_ANSWERED Event.CALL_CREATED Event.USER_UPDATED Event.USER_DELETED

Proposal Allocations

The STFC have the proposal allocations app to integrate the proposal system with our other systems currently. It is currently listening to the user_office_backend.fanout exchange for the following events:

  • PROPOSAL_UPDATED

  • PROPOSAL_SUBMITTED

  • CALL_CREATED

  • PROPOSAL_STATUS_CHANGED_BY_USER

  • TOPIC_ANSWERED

STFC RabbitMQ Config

We have set up a user account and vhost for our applications to use, this has can be set up through the web interface.

The vhost name is proposals with default config. The user account is proposal-submission-user and password should be set the one stored in rabbitmq-user-pass in BisAppSettings

 

Related content