Skip to content

Commit ec5101f

Browse files
committed
renaming
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
1 parent 11c6eb2 commit ec5101f

5 files changed

Lines changed: 33 additions & 16 deletions

File tree

docs/examples/jms_queue/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RabbitMQ AMQP 1.0 Go Client: https://github.com/rabbitmq/rabbitmq-amqp-go-client
22
// RabbitMQ AMQP 1.0 documentation: https://www.rabbitmq.com/docs/amqp
3-
// This example mirrors getting_started but declares a JMS queue via JmsQueueSpecification
3+
// This example mirrors getting_started but declares a JMS queue via JMSQueueSpecification
44
// (RabbitMQ queue type "jms"). JMS queues are available on Tanzu RabbitMQ 4.x; see:
55
// https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-rabbitmq-oci/4-2/tanzu-rabbitmq-oci-image/site-overview.html
66
// example path: https://github.com/rabbitmq/rabbitmq-amqp-go-client/tree/main/docs/examples/jms_queue/main.go
@@ -50,7 +50,7 @@ func main() {
5050
}
5151

5252
// Declare a JMS queue (x-queue-type=jms). Optional queue arguments go in Arguments.
53-
queueInfo, err := management.DeclareQueue(context.TODO(), &rmq.JmsQueueSpecification{
53+
queueInfo, err := management.DeclareQueue(context.TODO(), &rmq.JMSQueueSpecification{
5454
Name: queueName,
5555
})
5656

pkg/rabbitmqamqp/amqp_connection_recovery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (q *queueRecoveryRecord) toIQueueSpecification() IQueueSpecification {
120120
Arguments: q.arguments,
121121
}
122122
case Jms:
123-
return &JmsQueueSpecification{
123+
return &JMSQueueSpecification{
124124
Name: q.queueName,
125125
Arguments: q.arguments,
126126
}

pkg/rabbitmqamqp/amqp_queue_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ var _ = Describe("AMQP Queue test ", func() {
247247
Expect(result).To(BeNil())
248248
})
249249

250+
It("should fail if declare a JMS queue in the open source RabbitMQ", func() {
251+
queueName := generateName("should fail if declare a JMS queue in the open source RabbitMQ")
252+
_, err := management.DeclareQueue(context.TODO(), &JMSQueueSpecification{
253+
Name: queueName,
254+
})
255+
Expect(err).NotTo(BeNil())
256+
Expect(err.Error()).To(ContainSubstring("JMSQueueSpecification is only supported on Tanzu RabbitMQ 4.3 or later"))
257+
258+
})
259+
250260
// default
251261
It("AMQP Declare Queue with DefaultQueueSpecification should succeed", func() {
252262
queueName := generateName("AMQP Declare Queue with DefaultQueueSpecification should succeed")

pkg/rabbitmqamqp/entities.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
IQueueSpecification represents the specification of a queue.
2323
The implementation of the queue specification can be used to declare a queue with the specified properties and arguments.
2424
The client provides multiple implementations of the queue specification for different use cases,
25-
such as DefaultQueueSpecification, QuorumQueueSpecification, ClassicQueueSpecification, JmsQueueSpecification, and AutoGeneratedQueueSpecification.
25+
such as DefaultQueueSpecification, QuorumQueueSpecification, ClassicQueueSpecification, JMSQueueSpecification, and AutoGeneratedQueueSpecification.
2626
The client implementations are helpers that cover the most common use cases, but you can implement your own queue
2727
specification by implementing the IQueueSpecification interface.
2828
*/
@@ -481,9 +481,9 @@ func (s *StreamQueueSpecification) validate(*featuresAvailable) error {
481481
}
482482

483483
/*
484-
JmsQueueSpecification represents the specification of a JMS queue (RabbitMQ queue type "jms").
484+
JMSQueueSpecification represents the specification of a JMS queue (RabbitMQ queue type "jms").
485485
*/
486-
type JmsQueueSpecification struct {
486+
type JMSQueueSpecification struct {
487487
Name string
488488
Arguments map[string]any
489489
AutoExpire int64
@@ -499,23 +499,23 @@ type JmsQueueSpecification struct {
499499
SelectorFields []string
500500
}
501501

502-
func (j *JmsQueueSpecification) name() string {
502+
func (j *JMSQueueSpecification) name() string {
503503
return j.Name
504504
}
505505

506-
func (j *JmsQueueSpecification) isAutoDelete() bool {
506+
func (j *JMSQueueSpecification) isAutoDelete() bool {
507507
return false
508508
}
509509

510-
func (j *JmsQueueSpecification) isExclusive() bool {
510+
func (j *JMSQueueSpecification) isExclusive() bool {
511511
return false
512512
}
513513

514-
func (j *JmsQueueSpecification) queueType() TQueueType {
514+
func (j *JMSQueueSpecification) queueType() TQueueType {
515515
return Jms
516516
}
517517

518-
func (j *JmsQueueSpecification) buildArguments() map[string]any {
518+
func (j *JMSQueueSpecification) buildArguments() map[string]any {
519519
result := j.Arguments
520520
if result == nil {
521521
result = map[string]any{}
@@ -550,8 +550,15 @@ func (j *JmsQueueSpecification) buildArguments() map[string]any {
550550
return result
551551
}
552552

553-
func (j *JmsQueueSpecification) validate(*featuresAvailable) error {
554-
return nil
553+
func (j *JMSQueueSpecification) validate(f *featuresAvailable) error {
554+
// valid only if it is tanzu
555+
if f.isTanzu && f.is43rMore {
556+
return nil
557+
}
558+
// error not support for open source RabbitMQ
559+
560+
return fmt.Errorf("JMSQueueSpecification is only supported on Tanzu RabbitMQ 4.3 or later")
561+
555562
}
556563

557564
// durationToMaxAge converts a time.Duration to the RabbitMQ stream x-max-age string format.

pkg/rabbitmqamqp/entities_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ var _ = Describe("Entities", func() {
8686
})
8787
})
8888

89-
Describe("JmsQueueSpecification", func() {
89+
Describe("JMSQueueSpecification", func() {
9090
It("should always set x-queue-type to jms and fixed durability flags", func() {
91-
spec := &JmsQueueSpecification{Name: "my-jms-queue"}
91+
spec := &JMSQueueSpecification{Name: "my-jms-queue"}
9292
Expect(spec.isAutoDelete()).To(BeFalse())
9393
Expect(spec.isExclusive()).To(BeFalse())
9494
Expect(spec.queueType()).To(Equal(Jms))
@@ -97,7 +97,7 @@ var _ = Describe("Entities", func() {
9797
})
9898

9999
It("should merge optional arguments", func() {
100-
spec := &JmsQueueSpecification{
100+
spec := &JMSQueueSpecification{
101101
Name: "my-jms-queue",
102102
Arguments: map[string]any{"x-max-length-bytes": int64(1000)},
103103
}

0 commit comments

Comments
 (0)