Code Samples
C# — Two vhosts / Same queue name
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using System.Text;
var fixturesFactory = new ConnectionFactory {
HostName = "your-rabbitmq-host",
Port = 5671,
UserName = "fixtures-username",
Password = "fixtures-password",
VirtualHost = "fixtures",
Ssl = new SslOption { Enabled = true, ServerName = "your-rabbitmq-host" }
};
using var fxConn = fixturesFactory.CreateConnection();
using var fxCh = fxConn.CreateModel();
string qname = $"_{customerPackageId}_";
fxCh.QueueDeclare(qname, durable: true, exclusive: false, autoDelete: false);
var tipsFactory = new ConnectionFactory {
HostName = "your-rabbitmq-host",
Port = 5671,
UserName = "tips-username",
Password = "tips-password",
VirtualHost = "tips",
Ssl = new SslOption { Enabled = true, ServerName = "your-rabbitmq-host" }
};
using var tpConn = tipsFactory.CreateConnection();
using var tpCh = tpConn.CreateModel();
tpCh.QueueDeclare(qname, durable: true, exclusive: false, autoDelete: false);
void Consume(IModel ch, string queue, Action<string> handle) {
var consumer = new EventingBasicConsumer(ch);
consumer.Received += (_, ea) => handle(Encoding.UTF8.GetString(ea.Body.ToArray()));
ch.BasicConsume(queue: queue, autoAck: true, consumer: consumer);
}
Consume(fxCh, qname, json => {
// Upsert fixture by body.fixtureId (delta-only)
});
Consume(tpCh, qname, json => {
// Parse header.tipEventType: 1=Added, 2=Removed
// Join by body.fixtureId; for Added: body.tips[] (Tip objects); for Removed: body.tips[] (IDs)
});Python (pika) — Two vhosts / Same queue name
Java — Two vhosts / Same queue name
Last updated
Was this helpful?