# KubeMQ Bridges

KubeMQ Bridges bridge, replicate, aggregate, and transform messages between KubeMQ clusters no matter where they are, allowing to build a true cloud-native messaging single network running globally.

**Key Features**:

* **Runs anywhere**  - Kubernetes, Cloud, on-prem, anywhere
* **Stand-alone** - small docker container/binary
* **Build Any Topology** - connects KubeMQ clusters in 1:1, 1:n , n:1, n:n
* **Middleware Supports** - Logs, Metrics, Retries, and Rate Limiters
* **Easy Configuration** - simple yaml file builds your topology

**An example of a use case:**

![use-case](https://2828835384-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2Fsync%2F65f555c1f6ae32cd3210542d1543817de3696cc3.jpeg?generation=1607521609852018\&alt=media)

## Concept

KubeMQ Bridges' concept is bridging between sources and targets, thus Bindings.

Binding can be any source kinds to any target kinds, as shown below:

![concept](https://2828835384-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2Fsync%2F0de782b470d0af4a39e09eb3de7b158cf2a5a1f1.jpeg?generation=1607521613772259\&alt=media)

KubeMQ Bridges can support any binding topology :

| Topology  | Description                                                                                   | Sources-Targets         |
| --------- | --------------------------------------------------------------------------------------------- | ----------------------- |
| Bridge    | a 1:1 connectivity mainly for sync type of messages                                           | one source to 1 target  |
| Replicate | a 1:n connectivity allowing  replicating messages between clusters                            | one source to n targets |
| Aggregate | an n:1 connectivity allowing aggregating streams fo messages from clusters to a single target | n source to 1 target    |
| Transform | an n:n mix and match sources and targets in many to many topology                             | n sources to n targets  |

### Bridge

![bridge](https://2828835384-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2Fsync%2F0c210a26c7a07dad4c5c9ef3a8348647c0f102a5.jpeg?generation=1607521612778599\&alt=media)

### Replicate

![replicate](https://2828835384-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2Fsync%2F8782acf6977bb8c9854353498a3a8c5da48db500.jpeg?generation=1607521610808126\&alt=media)

### Aggregate

![aggregate](https://2828835384-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2Fsync%2F2215b7c219eedced0bf8c3bfec7684210d17fae4.jpeg?generation=1607521740820600\&alt=media)

### Transform

![transform](https://2828835384-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2b9dwAGbMPWty0fPGr%2Fsync%2Fafeb877e80c86c215e390a254eb0e0f17dd3e301.jpeg?generation=1607521611774266\&alt=media)

## Middlewares

In bindings configuration, KubeMQ Bridges supports middleware setting for each pair of source and target bindings.

These properties contain middleware information settings as follows:

### Logs Middleware

KubeMQ Bridges supports level based logging to console according to as follows:

| Property   | Description       | Possible Values                          |
| ---------- | ----------------- | ---------------------------------------- |
| log\_level | log level setting | "debug","info","error"                   |
|            |                   | "" - indicate no logging on this binding |

An example for only error level log to console:

```yaml
bindings:
  - name: sample-binding 
    properties: 
      log_level: error
    sources:
    ......
```

### Retry Middleware

KubeMQ Bridges supports Retries' target execution before reporting of error back to the source on failed execution.

Retry middleware settings values:

| Property                         | Description                                           | Possible Values                             |
| -------------------------------- | ----------------------------------------------------- | ------------------------------------------- |
| retry\_attempts                  | how many retries before giving up on target execution | default - 1, or any int number              |
| retry\_delay\_milliseconds       | how long to wait between retries in milliseconds      | default - 100ms or any int number           |
| retry\_max\_jitter\_milliseconds | max delay jitter between retries                      | default - 100ms or any int number           |
| retry\_delay\_type               | type of retry delay                                   | "back-off" - delay increase on each attempt |
|                                  |                                                       | "fixed" - fixed time delay                  |
|                                  |                                                       | "random" - random time delay                |

An example of 3 retries with back-off strategy:

```yaml
bindings:
  - name: sample-binding 
    properties: 
      retry_attempts: 3
      retry_delay_milliseconds: 1000
      retry_max_jitter_milliseconds: 100
      retry_delay_type: "back-off"
    sources:
    ......
```

### Rate Limiter Middleware

KubeMQ Sources support a Rate Limiting of target executions.

Rate Limiter middleware settings values:

| Property          | Description                                    | Possible Values                |
| ----------------- | ---------------------------------------------- | ------------------------------ |
| rate\_per\_second | how many executions per second will be allowed | 0 - no limitation              |
|                   |                                                | 1 - n integer times per second |

An example for 100 executions per second:

```yaml
bindings:
  - name: sample-binding 
    properties: 
      rate_per_second: 100
    source:
    ......
```
