Skip to content

Commit

Permalink
Shovel example (#161)
Browse files Browse the repository at this point in the history
* Add example for shovel
  • Loading branch information
ChunyiLyu committed Jun 10, 2021
1 parent 0e5160c commit d2e995e
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ You can create RabbitMQ resources:
6. [Policy](./docs/examples/policies)
7. [Permissions](./docs/examples/permissions)
8. [Federations](./docs/examples/federations)
9. [Shovels](./docs/examples/shovels)

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/federations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In this example, we will create federation between exchanges from two different vhosts in the same RabbitmqCluster.

Before creating any topology objects with Messaging Topology Operator, please deploy a RabbitmqCluster named `example-rabbit`, or any name you see fit.
You can pick any RabbitmqCluster example from the [cluster operator repo](https://github.com/rabbitmq/cluster-operator/blob/main/docs/examples).
You will need to enable the `rabbitmq_federation` plugin and here is an example from the [cluster operator repo](https://github.com/rabbitmq/cluster-operator/blob/main/docs/examples/plugins/rabbitmq.yaml) about enabling additional plugins.

After the RabbitMQ cluster is successfully created, you need to get username and password of the default user for this RabbitMQ cluster:

Expand Down
28 changes: 28 additions & 0 deletions docs/examples/shovels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Shovel Example

Shovel can move messages between move messages reliably and continually (typically between queues).
In this example, we will declare a dynamic Shovel that moves messages from a classic queue to a quorum queue in the same RabbitmqCluster.
The example can be used when you want to migrate from classic or mirrored queues to quorum queues.

Before creating any topology objects with Messaging Topology Operator, please deploy a RabbitmqCluster named `example-rabbit`, or any name you see fit. You will need to enable the `rabbitmq_shovel` plugin and here is an example from the [cluster operator repo](https://github.com/rabbitmq/cluster-operator/blob/main/docs/examples/plugins/rabbitmq.yaml) about enabling additional plugins.

After the RabbitMQ cluster is successfully created, you need to get username and password of the default user for this RabbitMQ cluster:

```bash
kubectl get secret example-rabbit-default-user -o jsonpath='{.data.username}' | base64 --decode
kubectl get secret example-rabbit-user -o jsonpath='{.data.password}' | base64 --decode
```
Save the username and password, because we need both later to construct the source and destination URI.

This example includes (please create in order):

1. two vhosts: 'source' and 'destination'
1. a Kubernetes secret 'shovel-secret' containing the shovel source and destination URIs
1. a classic queue 'source-queue' in vhost 'source' vhost
1. a quorum queue 'destination-queue' in vhost 'destination'
1. shovel 'shovel-example' between queue 'source-queue' and queue 'destination-queue'

After all topology objects are created, messages in 'source queue'
will be moved into 'destination-queue'.

Learn [more about RabbitMQ Dynamic Shovel](https://www.rabbitmq.com/shovel-dynamic.html).
27 changes: 27 additions & 0 deletions docs/examples/shovels/queues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: rabbitmq.com/v1beta1
kind: Queue
metadata:
name: source-queue
namespace: rabbitmq-system
spec:
name: source-queue
vhost: "source"
autoDelete: false
durable: true
rabbitmqClusterReference:
name: example-rabbit
---
apiVersion: rabbitmq.com/v1beta1
kind: Queue
metadata:
name: destination-queue
namespace: rabbitmq-system
spec:
name: destination-queue
vhost: "destination"
type: quoum
autoDelete: false
durable: true
rabbitmqClusterReference:
name: example-rabbit
9 changes: 9 additions & 0 deletions docs/examples/shovels/shovel-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: v1
kind: Secret
metadata:
name: shovel-secret
type: Opaque
data:
destUri: # encoded value for shovel destination URI; to learn about how to construct a valid uri, see: https://www.rabbitmq.com/uri-spec.html
srcUri: # encoded value shove source URI
15 changes: 15 additions & 0 deletions docs/examples/shovels/shovel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# for more information, see: https://www.rabbitmq.com/shovel-dynamic.html
---
apiVersion: rabbitmq.com/v1beta1
kind: Shovel
metadata:
name: shovel-example
namespace: rabbitmq-system
spec:
name: "shovel-example"
uriSecret:
name: shovel-secret
srcQueue: "source-queue"
destQueue: "destination-queue"
rabbitmqClusterReference:
name: example-rabbit
20 changes: 20 additions & 0 deletions docs/examples/shovels/vhosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: rabbitmq.com/v1beta1
kind: Vhost
metadata:
name: source-vhost
namespace: rabbitmq-system
spec:
name: source
rabbitmqClusterReference:
name: example-rabbit
---
apiVersion: rabbitmq.com/v1beta1
kind: Vhost
metadata:
name: destination-vhost
namespace: rabbitmq-system
spec:
name: destination
rabbitmqClusterReference:
name: example-rabbit

0 comments on commit d2e995e

Please sign in to comment.