Skip to content

Instantly share code, notes, and snippets.

View johanrhodin's full-sized avatar

Johan Rhodin johanrhodin

View GitHub Profile

RabbitMQ test with different libraries

I made a few tests with different client libraries.

Environment:

  • Laptop 12 cores, 32 gb ram
  • Two rabbitmq nodes in cluster ( same machine)
  • RabbitMQ version 3.7.13 - Erlang 21.2.4
  • 64 async threads for each server
  • Ubuntu 18.04
@johanrhodin
johanrhodin / create_delete_shovel
Created June 19, 2019 21:20
Use curl to create and delete a RabbitMQ shovel
curl -i -v -X PUT -H 'Content-Type: application/json' https://vhost:[email protected]/api/parameters/shovel/vhost/my-shovel2 -d '{"value":{"src-protocol": "amqp091","src-uri":"amqp://vhost@/vhost","src-queue":"q1","dest-protocol": "amqp091", "dest-uri": "amqp://vhost@/vhost","dest-queue": "q2"}}'
curl -i -v -X DELETE -H 'Content-Type: application/json' https://vhost:[email protected]/api/parameters/shovel/vhost/my-shovel2
@johanrhodin
johanrhodin / vhosts starting
Created May 8, 2020 04:04
Count vhosts that has started
bash << EOF
logpath=("/var/log/rabbitmq/[email protected]")
numbervhosts=$(expr $(sudo rabbitmqctl list_vhosts | wc -l) - $num)
startnr=$(grep -n "Starting RabbitMQ" $logpath | tail -1 | cut -d : -f 1) # Last RabbitMQ Starting
startedvhosts=$(sed -n "$startnr"',$p' $logpath | grep -n "Starting message stores for vhost" | wc -l)
awk -v nvh="$numbervhosts" -v svh="$startedvhosts" 'BEGIN{ print int(svh/nvh*100) }'
EOF
@johanrhodin
johanrhodin / pg2table.rb
Last active November 10, 2020 14:05
Fill up pg2table in RabbitMQ
#!/usr/bin/env ruby
require 'bunny'
require 'dotenv/load'
connection = Bunny.new ENV['CLOUDAMQP_URL3']
connection.start
channel = connection.create_channel # Declare a channel
for i in 1..1
puts "Creating queue #{i}"
@johanrhodin
johanrhodin / Minimum Viable Federation
Last active October 13, 2021 21:05
A small examples showing a working queue federation
# Minimum Viable Federation
#Upstream servers are the servers towards messages are originally published
#Downstream servers are where the messages get forwarded to
# 1. Two clusters
DOWNSTREAM_URL="amqps://tynqsojc:[email protected]/tynqsojc"
UPSTREAM_URL="amqps://prksmzye:[email protected]/prksmzye"
VHOST=tynqsojc
HTTPS_DOWNSTREAM="https://tynqsojc:[email protected]"
@johanrhodin
johanrhodin / shovel_overload
Last active September 13, 2021 17:42
Shovel issue were memory accumulates in connection writer and binaries.
# 1. On serverA Create a queue with 1M messages
bin/runjava com.rabbitmq.perf.PerfTest -y0 -p -u "q1" \
-s 1000 --id "q1" -ad false -f persistent \
-h $serverA \
-pmessages 1000000
# 2. On server B trigger the memory alarm.
sudo rabbitmqctl set_vm_memory_high_watermark 0
@johanrhodin
johanrhodin / 38_logging
Created October 20, 2021 21:15
Difference in logging style between RabbitMQ 3.8 and 3.9
2021-10-20 15:15:44.302 [error] <0.1264.0> ** Generic server <0.1264.0> terminating
** Last message in was {'$gen_cast',init_shovel}
** When Server state == {state,undefined,undefined,undefined,undefined,{<<"/">>,<<"logslogslogs">>},dynamic,#{ack_mode => on_confirm,dest => #{current => {<0.1331.0>,<0.1416.0>,<<"amqps://log-srv.rmq.cloudamqp.com/destvhost">>},dest_exchange => <<"logs.hostname2">>,fields_fun => #Fun<rabbit_shovel_parameters.7.125748776>,module => rabbit_amqp091_shovel,props_fun => #Fun<rabbit_shovel_parameters.8.125748776>,resource_decl => #Fun<rabbit_shovel_parameters.6.125748776>,uris => ["amqps://hostname2:[email protected]/destvhost"]},name => <<"logslogslogs">>,reconnect_delay => 5,shovel_type => dynamic,source => #{current => {<0.1269.0>,<0.1302.0>,<<"amqp://">>},delete_after => never,module => rabbit_amqp091_shovel,prefetch_count => 100,queue => <<"logslogslogs">>,resource_decl => #Fun<rabbit_shovel_parameters.10.125748776>,source_exchange_key => <<>>,uris => ["amqp://"
@johanrhodin
johanrhodin / left_over_connection.rb
Created April 25, 2022 20:38
Connection is left over when disk free alarm is in place
require 'amqp-client'
require 'dotenv/load'
NRM = 1
AMQPURL = ENV.fetch('CLOUDAMQP_URL')
conn = AMQP::Client.new(AMQPURL, connection_name:'leftover-connection').connect
ch = conn.channel
ch.confirm_select
@johanrhodin
johanrhodin / osiris_offset_out_of_range.log.txt
Created September 9, 2022 19:51
Random issue with RabbitMQ Streams: badmatch,{error,einval} and offset_out_of_range
2022-09-09 19:35:30.047624+00:00 [debug] <0.11717.17> rabbit_stream_coordinator: running action: 'start_writer' for acqokxym_s1_1662752130037252903 on node 'rabbit@test-tall-wheat-goat-01' in epoch 1
2022-09-09 19:35:30.048177+00:00 [info] <0.18479.445> Stream: acqokxym_s1_1662752130037252903 will use /var/lib/rabbitmq/rabbit@test-tall-wheat-goat-01/stream/acqokxym_s1_1662752130037252903 for osiris log data directory
2022-09-09 19:35:30.048344+00:00 [info] <0.18478.445> rabbit_stream_coordinator: started writer acqokxym_s1_1662752130037252903 on 'rabbit@test-tall-wheat-goat-01' in 1
2022-09-09 19:35:30.048482+00:00 [debug] <0.18479.445> osiris_log:init/1 stream acqokxym_s1_1662752130037252903 max_segment_size_bytes: 1234,
2022-09-09 19:35:30.048482+00:00 [debug] <0.18479.445> max_segment_size_chunks 256000, retention [{max_bytes,1234}]
2022-09-09 19:35:30.049105+00:00 [debug] <0.18479.445> osiris_log: open_new_segment acqokxym_s1_1662752130037252903: 00000000000000000000.segment
2022-09-09 19:35:30