> For the complete documentation index, see [llms.txt](https://algolytics-technologies.gitbook.io/algolytics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algolytics-technologies.gitbook.io/algolytics/scoring.one-platform/tutorials/sending-data-to-remote-queues.md).

# Sending data to remote queues

Scoring.one provides API for sending data to remote systems via queue directly from scenarios. There are pre-defined queues dedicated to sending data to RDBMS (i.e. „sce-postgres-data”)&#x20;

Example in Groovy:

{% code overflow="wrap" %}

```groovy
import com.rabbitmq.client.*
amqpManager.checkConnection()
if (!amqpManager.channelExists(chName)) {
   amqpManager.createChannel(chName)
}
amqpManager.publish(chName, JsonOutput.toJson(BEnvelope),[eventGroup: BEnvelope['eventGroup']])
```

{% endcode %}

Where arguments of <kbd>publish</kbd> method are:

<kbd>chName</kbd> – rabbitMQ's channel name (String)

<kbd>JsonOutput.toJson(BEnvelope)</kbd> – message content (String)

<kbd>\[eventGroup: BEnvelope\['eventGroup']]</kbd> – message headers (Map\<String, Object>); this argument is optional and may be omitted&#x20;

The full definition of the publish method, including overloaded variants:

```groovy
void publish(String channelName, String channelMsg)
void publish(String channelName, String channelMsg, Map<String, Object> headers)
void publish(String channelName, String channelMsg, boolean waitForConfirms, Map<String, Object> headers)
```

Where:

<kbd>channelName</kbd> – the name of the RabbitMQ channel created by createChannel(channelName)

<kbd>channelMsg</kbd> – the message body

<kbd>waitForConfirms</kbd> – whether to wait until all messages published since the last call have been either ack'd or nack'd by the broker&#x20;

<kbd>headers</kbd> – a user-defined map of key-value pairs used to attach custom metadata to the message. These headers can be used by consumers or routing logic to inspect, filter, or process messages based on application-specific information. Each key must be a string, and the values can be of various AMQP-compatible types (e.g., String, Integer, Boolean, byte\[])

A message intended for persistence in a relational database should be a JSON object with the structure described as follows:

```yaml
Message:
type: object
  required:
    - table
    - schema
    - data
  properties:
    table:
      type: string
    schema:
      type: string
    data:
      type: object
      additionalProperties:
        oneOf:
          - type: string
          - type: number
          - type: boolean
    on_conflict: $ref: '#/components/schemas/OnConflict'
```

```yaml
OnConflict:
  type: object
  required:
    - index_column_names
    - action
  properties:
    index_column_names:
      type: array
      items:
        type: string
    action:
      type: string
      enum:
        - update
        - nothing
```

Example:

```json
{
  "table": "car",
  "schema": "public",
  "data": {
    "registration_number": "TK 49899",
    "number_of_doors": 4
  },
  "on_conflict": {
    "index_column_names": [
      "registration_number"
    ],
    "action": "update"
  }
}
```
