-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add page for RabbitMQ, fix links, add ELI information, other minor tw…
…eaks (#710)
- Loading branch information
Showing
12 changed files
with
280 additions
and
199 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
RabbitMQ is an open-source message broker that enables applications to communicate with each other asynchronously by sending and receiving messages. It is used within User Office to handle communication between different components of the system, particularly for routing messages related to proposal status actions. | ||
|
||
This page provides an overview of how RabbitMQ is integrated into the project, including details on configuration, message handling, and frontend display. | ||
|
||
## RabbitMQ in User Office Core | ||
|
||
When the status of a proposal changes, a message is sent to specific RabbitMQ exchanges, which then route the message to the appropriate services or components for further processing. | ||
|
||
Enable it in the [configuration](configuration.md). | ||
|
||
## Configuration of RabbitMQ Exchanges | ||
|
||
The RabbitMQ exchanges are configured using the `RabbitMQActionConfig` class. This class defines the exchanges to which messages will be sent when the status of a proposal changes. | ||
|
||
@ObjectType() | ||
export class RabbitMQActionConfig extends ProposalStatusActionConfigBase { | ||
@Field(() => [String], { nullable: true }) | ||
exchanges?: string[] | null; | ||
} | ||
|
||
**Exchanges:** The exchanges property is an array of strings, each representing the name of a RabbitMQ exchange. These exchanges are where messages related to proposal status changes are sent. | ||
|
||
## Backend Message Handling | ||
|
||
The `rabbitMQActionHandler` function in the backend is responsible for sending messages to RabbitMQ exchanges based on the configuration defined in `RabbitMQActionConfig`. | ||
|
||
export const rabbitMQActionHandler = async ( | ||
proposalStatusAction: ConnectionHasStatusAction, | ||
proposals: WorkflowEngineProposalType[] | ||
) => { | ||
const config = proposalStatusAction.config as RabbitMQActionConfig; | ||
if (!config.exchanges?.length) { | ||
return; | ||
} | ||
|
||
const messageDescription = | ||
'Proposal event successfully sent to the message broker'; | ||
|
||
return await Promise.all( | ||
config.exchanges.map((exchange) => | ||
publishMessageToTheEventBus(proposals, messageDescription, exchange) | ||
) | ||
); | ||
}; | ||
|
||
**Message Publishing:** This function takes in a `proposalStatusAction` and an array of proposals. It then publishes messages to each configured exchange by calling `publishMessageToTheEventBus`. | ||
|
||
If no exchanges are configured, the function exits early without performing any actions. | ||
|
||
## Frontend Display of RabbitMQ Exchanges | ||
|
||
On the frontend, the `RabbitMQActionConfig` component is responsible for displaying the RabbitMQ exchanges where messages are sent. This provides users with information of how and where proposal data is routed. | ||
|
||
type RabbitMQActionConfigProps = { | ||
exchanges: RabbitMqActionConfigType['exchanges']; | ||
}; | ||
|
||
const RabbitMQActionConfig = ({ exchanges }: RabbitMQActionConfigProps) => { | ||
return ( | ||
<Typography variant="subtitle1" color="black"> | ||
Messages with <i>proposal data</i> are sent to the following RabbitMQ exchanges:{' '} | ||
<ul style={{ margin: 0 }}> | ||
{exchanges?.map((exchange, index) => ( | ||
<li key={index}> | ||
<b>{exchange}</b> | ||
</li> | ||
))} | ||
</ul> | ||
</Typography> | ||
); | ||
}; | ||
|
||
export default RabbitMQActionConfig; | ||
|
||
The component renders a list of RabbitMQ exchanges, showing which exchanges are being used to route messages related to proposal data. | ||
|
||
## GraphQL Integration | ||
|
||
The `RabbitMQActionConfig` class is integrated into the project’s GraphQL API, allowing for dynamic configuration and querying of RabbitMQ settings. | ||
|
||
You can retrieve the RabbitMQ configuration using a GraphQL query: | ||
|
||
query { | ||
proposalStatusActionConfig { | ||
exchanges | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.