Configuring Message Headers
In general, the source message header is propagated through the Micro-Integration to the target message header. When you configure the Micro-Integration, you can optionally configure mappings for the header information between the external system and the PubSub+event broker service.
If you want to map the source message header to a target message header, you do so using the Target Header Mappings step when you create a Micro-Integration or modify them after.
To specify the mappings, you must use the Spring Expression Language (SpEL). For examples to use SpEL expressions, see SpEL Examples for Target Header Mappings.
It's important to recognize that there are a set of common source and target message headers that you can use that are available for all Micro-Integration Types as well as specific message headers depending on the Micro-Integration Type you are using. For information about the message headers that are available, see:
- Common Reserved Message Headers
- Common and Vendor-Specific Dynamic Producer Destinations
- Amazon SNS Message Headers
- Amazon SQS Message Headers
- Azure Service Bus Message Headers
- Google Cloud Pub/Sub Message Headers
- IBM MQ Message Headers
- Solace Message Headers
SpEL Examples for Target Header Mappings
The following are examples that show how to use a SpEL expression in the fields for the Target Header Mappings step when you create a mapping between the source message header and the target message header. To fully utilize the mappings, you should have a good understanding of how to use SpEL expressions. For example, to access the header attributes or payload, you use the headers
properties.
For more information about using Spring Expression Language (SpEL) expressions, see Spring Expression Language (SpEL). The following are how you would perform some header mapping operations:
- On the Target Header Mappings step, enter the following values to the following fields to map the Solace Correlation ID to the JMS correlation ID:
- Target Header Name:
jms_correlationId
- Header Expression:
headers.solace_correlationId
-
On the Target Header Mappings step, enter the following values to map the to the following fields header ID with custom prefix called
myprefix-
to a custom header name calledcustom-message-id
:- Target Header Name:
custom-message-id
- Header Expression:
'myprefix-' + headers.id
- Target Header Name:
Common Reserved Message Headers
The following are reserved header spaces that are common to configure all Micro-Integrations:
-
solace_
-
scst_
-
Any headers defined by the core Spring messaging framework. For more information, see Spring Integration: Message Headers.
Any headers with these prefixes (that are not defined by the Micro-Integration or any technology used by the Micro-Integration) may not be backwards compatible in future releases of this Micro-Integration.
Common and Vendor-Specific Dynamic Producer Destinations
To route messages to dynamic destinations at runtime, use the Configuring Message Headers described above to set the following headers. The following table contains both common and vendor-specific dynamic producer destinations.
Header Name | Type | Values | Applies To | Description |
---|---|---|---|---|
|
|
Any valid destination name |
Solace (PubSub+) JMS IBM MQ Amazon SQS Google Cloud Pub/Sub MQTT |
Specifies the name of the dynamic destination to publish to. Setting this header overrides the configured destination. |
|
|
|
Solace Amazon SQS Google Cloud Pub/Sub |
Specifies the destination type of the dynamic destination. When unspecified, the configured or default destination type is used. |
|
|
|
JMS IBM MQ |
Specifies the destination type of the dynamic destination. When unspecified, the configured or default destination type is used. |
|
|
Any valid destination name |
Google Cloud Pub/Sub |
Specifies the name of the dynamic destination to publish to. Setting this header overrides the configured destination. |
Amazon SNS Message Headers
To configure the common message headers for this Micro-Integration, see the following sections:
Amazon SQS Message Headers
To configure the common message headers for this Micro-Integration, see the following sections:
Azure Service Bus Message Headers
You can configure Azure Service Bus vendor-specific message headers using the following lists:
Dynamic Headers for Azure Service Bus
Azure Service Bus supports Azure Service Bus partitioning and message sessions of the Azure Service Bus by setting the following headers:
Header Name | Type | Access | Description |
---|---|---|---|
|
|
Read |
Sets a session ID of a message in the message header. |
|
|
Read |
Sets a partition key in the message header. |
The session ID has higher priority than the partition key. When both azure_partition_key
and azure_session_id
headers are set, the value of the session ID overwrites the value of the partition key.
To configure the common message headers for this Micro-Integration, see the following sections:
Google Cloud Pub/Sub Message Headers
You can configure Google Cloud Pub/Sub vendor-specific message headers using the following lists:
Message Header Mappings for Google Cloud Pub/Sub
The following Google Cloud Pub/Sub PubsubMessage
attributes are mapped to the following message properties:
Header Name | Type | Access | Description |
---|---|---|---|
|
|
Read |
The ID of the message, assigned by the Google Cloud Pub/Sub service when the message is published. See Google Cloud Pub/Sub PubsubMessage.getMessageId(). |
|
|
Read |
The time at which the message was published, populated by the Google Cloud Pub/Sub service when it receives the Publish call. |
|
|
Read |
The Google Cloud Pub/Sub message’s ordering key. See Google Cloud Pub/Sub PubsubMessage.getOrderingKey(). |
The following Solace message headers marked with Read
access are automatically forwarded to Google Cloud Pub/Sub messages, while headers with Write
access can be set using transformations.
Header Name | Type | Access | Description |
---|---|---|---|
|
|
Read/Write |
The application provided message ID. |
|
|
Read/Write |
The application provided message type. This value is used by applications only. |
|
|
Read/Write |
The correlation ID for the message. |
solace_dmqEligible
|
boolean
|
Write | Set the Solace message’s dmqEligible
header. |
solace_expiration
|
long
|
Write | Set the time at which the Solace message is set to expire. |
solace_priority
|
int
|
Write | Set the Solace message’s priority. |
solace_senderId
|
string
|
Read | The Sender ID for the Solace message. |
solace_senderTimestamp
|
long
|
Read | The time at which the Solace message was published. |
solace_sequenceNumber
|
string
|
Read | The application-defined sequence number set on the Solace message. |
Reserved Message Headers for Google Cloud Pub/Sub
The following is a reserved header space that can be used with Google Cloud Pub/Sub:
-
gcp_pubsub|goog
To configure the common message headers for this Micro-Integration, see the following sections:
IBM MQ Message Headers
You can configure IBM MQ vendor-specific message headers using the following lists:
JMS Message Headers
You can use the following message headers to get and set JMS message properties for IBM MQ.
Header Name | Type | Access | Description |
---|---|---|---|
|
|
Read/Write |
The correlation ID for the message. |
|
|
Read |
The delivery mode value specified for this message. |
|
|
Read |
The destination to which the message is being sent. |
|
|
Read |
The time at which the JMS message is set to expire. |
|
|
Read |
A value that uniquely identifies each message sent by a provider. |
|
|
Read/Write |
Specifies the message’s priority set on the send. When header is absent, JMS message is sent with default priority of 4. |
|
|
Read |
An indication of whether this message is being redelivered. |
|
|
Read/Write |
The Destination object to which a reply to this message should be sent. |
|
|
Read |
The time a message was handed off to a provider to be sent. |
|
|
Write |
Specifies the message’s time to live set on the send. When header is absent, JMS message is sent with default timeToLive of 0 (zero means that a message never expires). |
|
|
Read/Write |
The message type identifier supplied by the client when the message was sent. |
JMS Binder Headers
The following are JMS Binder Headers.
Header Name | Type | Access | Description |
---|---|---|---|
|
|
Read |
Specifies when the JMS message payload is null. Two cases exist:
|
Reserved Message Headers for IBM MQ
The following is a reserved header space that can be used with IBM MQ:
-
jms_
|JMS_
|JMSX
To configure the common message headers for this Micro-Integration, see the following sections:
Solace Message Headers
Solace headers exposed to the Micro-Integration are documented in the Spring Cloud Stream Binder for Solace PubSub+ documentation.