Skip to content

Commit 189408c

Browse files
authored
Restore the Azure Client (#11)
The null value is fixed here Azure/go-amqp#336 Signed-off-by: Gabriele Santomaggio <[email protected]>
1 parent 05f7cd9 commit 189408c

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

examples/getting_started/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
func main() {
1313
fmt.Printf("Getting started with AMQP Go AMQP 1.0 Client\n")
14-
1514
chStatusChanged := make(chan *mq.StatusChanged, 1)
1615

1716
go func(ch chan *mq.StatusChanged) {

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module github.com/rabbitmq/rabbitmq-amqp-go-client
33
go 1.22.0
44

55
require (
6-
github.com/Azure/go-amqp v0.0.0-00010101000000-000000000000
76
github.com/onsi/ginkgo/v2 v2.20.2
87
github.com/onsi/gomega v1.34.2
98
)
109

1110
require (
11+
github.com/Azure/go-amqp v1.1.1-0.20240913224415-f631e6909719 // indirect
1212
github.com/go-logr/logr v1.4.2 // indirect
1313
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
1414
github.com/google/go-cmp v0.6.0 // indirect
@@ -20,5 +20,3 @@ require (
2020
golang.org/x/tools v0.24.0 // indirect
2121
gopkg.in/yaml.v3 v3.0.1 // indirect
2222
)
23-
24-
replace github.com/Azure/go-amqp => github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/Azure/go-amqp v1.1.1-0.20240913224415-f631e6909719 h1:rL7yrEV9yputQV7T+Y9eJVmTVkK4B0aHlBc8TUITC5A=
2+
github.com/Azure/go-amqp v1.1.1-0.20240913224415-f631e6909719/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE=
13
github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48 h1:etxEtd7qkhJD34gpQesPbZuMJrqkc+ZOXqR3diVfGWs=
24
github.com/Gsantomaggio/go-amqp v0.0.0-20240905094626-af192b497e48/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE=
35
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

rabbitmq_amqp/amqp_binding.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package rabbitmq_amqp
22

3-
import "context"
3+
import (
4+
"context"
5+
"github.com/Azure/go-amqp"
6+
)
47

58
type AMQPBindingInfo struct {
69
}
@@ -46,6 +49,6 @@ func (b *AMQPBinding) Bind(ctx context.Context) error {
4649

4750
func (b *AMQPBinding) Unbind(ctx context.Context) error {
4851
bindingPathWithExchangeQueueKey := bindingPathWithExchangeQueueKey(b.sourceExchangeName, b.destinationQueue, b.bindingKey)
49-
_, err := b.management.Request(ctx, nil, bindingPathWithExchangeQueueKey, commandDelete, []int{responseCode204})
52+
_, err := b.management.Request(ctx, amqp.Null{}, bindingPathWithExchangeQueueKey, commandDelete, []int{responseCode204})
5053
return err
5154
}

rabbitmq_amqp/amqp_exchange.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package rabbitmq_amqp
22

3-
import "context"
3+
import (
4+
"context"
5+
"github.com/Azure/go-amqp"
6+
)
47

58
type AmqpExchangeInfo struct {
69
name string
@@ -56,7 +59,7 @@ func (e *AmqpExchange) IsAutoDelete() bool {
5659

5760
func (e *AmqpExchange) Delete(ctx context.Context) error {
5861
path := exchangePath(e.name)
59-
_, err := e.management.Request(ctx, nil, path, commandDelete, []int{responseCode204})
62+
_, err := e.management.Request(ctx, amqp.Null{}, path, commandDelete, []int{responseCode204})
6063
return err
6164
}
6265

rabbitmq_amqp/amqp_managent.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,14 @@ func (a *AmqpManagement) validateResponseCode(responseCode int, expectedResponse
154154
}
155155
}
156156

157-
return PreconditionFailed
157+
return errors.New(fmt.Sprintf("expected response code %d got %d", expectedResponseCodes, responseCode))
158158
}
159159

160160
func (a *AmqpManagement) request(ctx context.Context, id string, body any, path string, method string,
161161
expectedResponseCodes []int) (map[string]any, error) {
162-
amqpMessage := amqp.NewMessageWithValue(body)
162+
amqpMessage := &amqp.Message{
163+
Value: body,
164+
}
163165
s := commandReplyTo
164166
amqpMessage.Properties = &amqp.MessageProperties{
165167
ReplyTo: &s,

rabbitmq_amqp/amqp_queue.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rabbitmq_amqp
22

33
import (
44
"context"
5+
"github.com/Azure/go-amqp"
56
)
67

78
type AmqpQueueInfo struct {
@@ -161,7 +162,7 @@ func (a *AmqpQueue) Declare(ctx context.Context) (IQueueInfo, error) {
161162

162163
func (a *AmqpQueue) Delete(ctx context.Context) error {
163164
path := queuePath(a.name)
164-
_, err := a.management.Request(ctx, nil, path, commandDelete, []int{responseCode200})
165+
_, err := a.management.Request(ctx, amqp.Null{}, path, commandDelete, []int{responseCode200})
165166
return err
166167
}
167168

0 commit comments

Comments
 (0)