Service d'intégration CRM
C'est le microservice au centre de notre projet d'intégration. Il reçoit les messages des autres équipes via RabbitMQ, synchronise Salesforce et MySQL, puis déclenche la facturation et le mailing.
- API REST Salesforce avec OAuth et refresh tokens
- Des schémas XML/XSD valident chaque message
- Tourne dans Docker ; GitHub Actions lance les tests et le build
await this.channel.assertQueue(QUEUE_NAME, { durable: true });
await this.channel.assertQueue(KASSA_QUEUE, { durable: true });
await this.channel.assertQueue(DEAD_LETTER_QUEUE, {
durable: true,
arguments: { 'x-dead-letter-exchange': '' },
});
await this.channel.prefetch(1);
const consume = async (msg) => {
if (msg) {
try {
await this.handleMessage(msg);
} catch (err) {
console.log(`[receiver] Unhandled error in message handler: ${err}`);
}
}
};
this.channel.consume(QUEUE_NAME, consume, { noAck: false });
this.channel.consume(KASSA_QUEUE, consume, { noAck: false });
async _doTokenRefresh() {
const params = new URLSearchParams({
grant_type: 'refresh_token',
client_id: this.clientId,
client_secret: this.clientSecret,
refresh_token: this.refreshToken,
});
const resp = await fetch(SFConnection.TOKEN_URL, {
method: 'POST',
body: params,
});
if (resp.ok) {
return resp.json();
}
const text = await resp.text();
console.log(`[SF Connection] Token refresh failed (${resp.status}): ${text}`);
return null;
}
async apiCall(fn) {
if (!this.connection) return null;
try {
return await fn(this.connection);
} catch (err) {
if (String(err).includes('INVALID_SESSION_ID')) {
console.log('[SF Connection] Session expired, refreshing...');
if (await this.refresh()) {
return await fn(this.connection);
}
}
throw err;
}
}


