@@ -10,7 +10,12 @@ import (
1010
1111func main () {
1212
13- env := rmq .NewEnvironment ("amqp://guest:guest@localhost:5672/" , nil )
13+ // create 10 million UUIDs
14+
15+ env := rmq .NewEnvironment ("amqp://test:test@192.168.1.124:5672/" , & rmq.AmqpConnOptions {
16+
17+ MaxFrameSize : 2048 ,
18+ })
1419
1520 // Open a connection to the AMQP 1.0 server ( RabbitMQ >= 4.0)
1621 amqpConnection , err := env .NewConnection (context .Background ())
@@ -20,7 +25,7 @@ func main() {
2025 }
2126
2227 amqpConnection .Management ().DeleteQueue (context .Background (), "test" )
23- amqpConnection .Management ().DeclareQueue (context .Background (), & rmq.QuorumQueueSpecification {
28+ amqpConnection .Management ().DeclareQueue (context .Background (), & rmq.StreamQueueSpecification {
2429 Name : "test" ,
2530 })
2631
@@ -38,16 +43,23 @@ func main() {
3843
3944 switch state .(type ) {
4045 case * amqp.StateAccepted :
41- if atomic .AddInt32 (& confirmed , 1 )% 20_000 == 0 {
46+ if atomic .AddInt32 (& confirmed , 1 )% 50_000 == 0 {
4247 // confirmations per second
4348 rmq .Info ("Confirmations per second" , "value" , float64 (confirmed )/ time .Since (startDate ).Seconds ())
4449 }
50+
51+ if atomic .LoadInt32 (& confirmed ) == 2_500_000 {
52+ // time since the start
53+ rmq .Info ("Time to confirm all messages" , "value" , time .Since (startDate ).Seconds ())
54+ }
4555 default :
4656 panic ("Message not accepted" )
4757
4858 }
4959
5060 }
61+ // 1kb to bytes
62+ //bytes := make([]byte, 1_000)
5163
5264 //for i := 0; i < 500_000; i++ {
5365 // _, err := publisher.Publish(context.Background(), rmq.NewMessage(make([]byte, 1)))
@@ -58,14 +70,19 @@ func main() {
5870 // // message per second
5971 // rmq.Info("Sync Messages per second", "value", float64(i)/time.Since(startDate).Seconds())
6072 // }
73+ //
74+ // if i == 500_000-1 {
75+ // // time since the start
76+ // rmq.Info("Time to confirm all messages", "value", time.Since(startDate).Seconds())
77+ // }
6178 //}
6279
63- for i := 0 ; i < 500_000 ; i ++ {
64- err := publisher .PublishAsyncConfirmation (context .Background (), rmq .NewMessage (make ([]byte , 1 )), f )
80+ for i := 0 ; i < 2_500_000 ; i ++ {
81+ err := publisher .PublishAsyncConfirmation (context .Background (), rmq .NewMessage (make ([]byte , 1_000 )), f )
6582 if err != nil {
6683 rmq .Error ("Error publishing message" , err )
6784 }
68- if i % 20_000 == 0 {
85+ if i % 50_000 == 0 {
6986 // message per second
7087 rmq .Info ("Messages per second" , "value" , float64 (i )/ time .Since (startDate ).Seconds ())
7188 }
0 commit comments