livrare lot 2
This commit is contained in:
commit
8ecc78e729
763 changed files with 164593 additions and 0 deletions
72
backend/services/data-layer/didiQueue/init-queues.sh
Normal file
72
backend/services/data-layer/didiQueue/init-queues.sh
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
# Init script for RabbitMQ queue setup
|
||||
# This runs automatically when the container starts
|
||||
|
||||
set -e
|
||||
|
||||
# Wait for RabbitMQ to be ready
|
||||
until rabbitmqctl status > /dev/null 2>&1; do
|
||||
echo "Waiting for RabbitMQ to start..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "RabbitMQ is ready. Setting up queues..."
|
||||
|
||||
# Since we're merging all analysis services into one, we only need ONE queue
|
||||
# Create the unified analysis queue
|
||||
rabbitmqctl eval '
|
||||
rabbit_exchange:declare(
|
||||
{resource, <<"/">>, exchange, <<"analysis">>},
|
||||
topic,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
[]
|
||||
).' || true
|
||||
|
||||
# Declare the unified analysis queue with proper settings
|
||||
rabbitmqctl eval '
|
||||
rabbit_amqqueue:declare(
|
||||
{resource, <<"/">>, queue, <<"analysis_queue">>},
|
||||
true, % Durable
|
||||
false, % Not exclusive
|
||||
false, % Not auto-delete
|
||||
[], % No arguments
|
||||
none % No owner
|
||||
).' || true
|
||||
|
||||
# Bind the queue to the exchange
|
||||
rabbitmqctl eval '
|
||||
rabbit_binding:add_explicit(
|
||||
{binding,
|
||||
{resource, <<"/">>, exchange, <<"analysis">>},
|
||||
<<"analysis.*">>,
|
||||
{resource, <<"/">>, queue, <<"analysis_queue">>},
|
||||
[]
|
||||
}
|
||||
).' || true
|
||||
|
||||
# Optional: Create a dead letter queue for failed messages
|
||||
rabbitmqctl eval '
|
||||
rabbit_amqqueue:declare(
|
||||
{resource, <<"/">>, queue, <<"analysis_dlq">>},
|
||||
true, % Durable
|
||||
false, % Not exclusive
|
||||
false, % Not auto-delete
|
||||
[], % No arguments
|
||||
none % No owner
|
||||
).' || true
|
||||
|
||||
echo "✅ Queue setup complete!"
|
||||
echo "Created queues:"
|
||||
echo " - analysis_queue (main queue for all analysis types)"
|
||||
echo " - analysis_dlq (dead letter queue for failed messages)"
|
||||
|
||||
# Set queue policies for message TTL and retry
|
||||
rabbitmqctl set_policy analysis-retry \
|
||||
"analysis_queue" \
|
||||
'{"message-ttl":86400000, "dead-letter-exchange":"", "dead-letter-routing-key":"analysis_dlq"}' \
|
||||
--priority 0 \
|
||||
--apply-to queues || true
|
||||
|
||||
echo "✅ Queue policies configured!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue