Send message to Solace queues with persistent deliveryv3.11+
Configure the plugin to connect to a Solace broker using basic authentication, and send messages to multiple queues with persistent delivery. This example uses a statically configured message and includes a Lua function to transform message content before sending (in this case the message that the plugin will send is “HELLO”).
Environment variables
-
SOLACE_HOST: The IPv4 or IPv6 address or hostname of the Solace broker to connect to. For example,tcp://127.0.0.1:55555. -
SOLACE_USERNAME: The username used withBASICauthentication scheme when connecting to an event broker. -
SOLACE_PASSWORD: The password used withBASICauthentication scheme when connecting to an event broker. -
QUEUE_NAME: The name of the first destination queue. -
ANOTHER_QUEUE_NAME: The name of the second destination queue.
Add this section to your kong.yaml configuration file:
_format_version: "3.0"
plugins:
- name: solace-upstream
config:
session:
host: ${{ env "DECK_SOLACE_HOST" }}
vpn_name: default
authentication:
scheme: BASIC
username: ${{ env "DECK_SOLACE_USERNAME" }}
password: ${{ env "DECK_SOLACE_PASSWORD" }}
message:
destinations:
- name: ${{ env "DECK_QUEUE_NAME" }}
type: QUEUE
- name: ${{ env "DECK_ANOTHER_QUEUE_NAME" }}
type: QUEUE
delivery_mode: PERSISTENT
default_content: hello
functions:
- return string.upper(message)Make the following request:
curl -i -X POST http://localhost:8001/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "solace-upstream",
"config": {
"session": {
"host": "'$SOLACE_HOST'",
"vpn_name": "default",
"authentication": {
"scheme": "BASIC",
"username": "'$SOLACE_USERNAME'",
"password": "'$SOLACE_PASSWORD'"
}
},
"message": {
"destinations": [
{
"name": "'$QUEUE_NAME'",
"type": "QUEUE"
},
{
"name": "'$ANOTHER_QUEUE_NAME'",
"type": "QUEUE"
}
],
"delivery_mode": "PERSISTENT",
"default_content": "hello",
"functions": [
"return string.upper(message)"
]
}
}
}
'Add this section to your kong.yaml configuration file:
_format_version: "3.0"
plugins:
- name: solace-upstream
service: serviceName|Id
config:
session:
host: ${{ env "DECK_SOLACE_HOST" }}
vpn_name: default
authentication:
scheme: BASIC
username: ${{ env "DECK_SOLACE_USERNAME" }}
password: ${{ env "DECK_SOLACE_PASSWORD" }}
message:
destinations:
- name: ${{ env "DECK_QUEUE_NAME" }}
type: QUEUE
- name: ${{ env "DECK_ANOTHER_QUEUE_NAME" }}
type: QUEUE
delivery_mode: PERSISTENT
default_content: hello
functions:
- return string.upper(message)Make sure to replace the following placeholders with your own values:
serviceName|Id: Theidornameof the service the plugin configuration will target.
Make the following request:
curl -i -X POST http://localhost:8001/services/{serviceName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "solace-upstream",
"config": {
"session": {
"host": "'$SOLACE_HOST'",
"vpn_name": "default",
"authentication": {
"scheme": "BASIC",
"username": "'$SOLACE_USERNAME'",
"password": "'$SOLACE_PASSWORD'"
}
},
"message": {
"destinations": [
{
"name": "'$QUEUE_NAME'",
"type": "QUEUE"
},
{
"name": "'$ANOTHER_QUEUE_NAME'",
"type": "QUEUE"
}
],
"delivery_mode": "PERSISTENT",
"default_content": "hello",
"functions": [
"return string.upper(message)"
]
}
}
}
'Make sure to replace the following placeholders with your own values:
serviceName|Id: Theidornameof the service the plugin configuration will target.
Add this section to your kong.yaml configuration file:
_format_version: "3.0"
plugins:
- name: solace-upstream
route: routeName|Id
config:
session:
host: ${{ env "DECK_SOLACE_HOST" }}
vpn_name: default
authentication:
scheme: BASIC
username: ${{ env "DECK_SOLACE_USERNAME" }}
password: ${{ env "DECK_SOLACE_PASSWORD" }}
message:
destinations:
- name: ${{ env "DECK_QUEUE_NAME" }}
type: QUEUE
- name: ${{ env "DECK_ANOTHER_QUEUE_NAME" }}
type: QUEUE
delivery_mode: PERSISTENT
default_content: hello
functions:
- return string.upper(message)Make sure to replace the following placeholders with your own values:
routeName|Id: Theidornameof the route the plugin configuration will target.
Make the following request:
curl -i -X POST http://localhost:8001/routes/{routeName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "solace-upstream",
"config": {
"session": {
"host": "'$SOLACE_HOST'",
"vpn_name": "default",
"authentication": {
"scheme": "BASIC",
"username": "'$SOLACE_USERNAME'",
"password": "'$SOLACE_PASSWORD'"
}
},
"message": {
"destinations": [
{
"name": "'$QUEUE_NAME'",
"type": "QUEUE"
},
{
"name": "'$ANOTHER_QUEUE_NAME'",
"type": "QUEUE"
}
],
"delivery_mode": "PERSISTENT",
"default_content": "hello",
"functions": [
"return string.upper(message)"
]
}
}
}
'Make sure to replace the following placeholders with your own values:
routeName|Id: Theidornameof the route the plugin configuration will target.