I write this post to share how to do the following things in Boomi :
- Publish a message to Solace with custom headers
- Listen for message and get the headers, parsing the custom headers stored in “userProperties” header
Boomi is an iPaaS solution (other well known iPaaS : TIBCO Cloud Integration, Mulesoft)
You can read about Solace Headers here :
- Tom Fairbairn blog post : https://solace.com/blog/inside-a-solace-message-using-header-properties/
- I’ve uploaded a document that reference most of headers: check the bottom of this post.“SMF header reference”
Post a message with customer header in BOOMI
First be sure to select the following connector to connect to Solace :
“Solace PubSub+ Platform - Partner connector”
This connector is developed by Solace.
Pass static key=value pairs
Since the version 220 published on the 10th of July you can pass static key value pairs as headers from the “Operation” :
The result is the following :
your message is published with the standard headers + static_header_key=static_header_value header.
In a future release, you’ll also be able to pass dynamic data as well.
Pass dynamic key value pairs
As of now, to pass dynamic data, you need to
- Use the “Set Property” Shape
- Type : Document property
- Source Type : connector
- connectors : select your “Solace PubSub+ Platform - Partner connector” instance
- Property : User Property
As a value, you need to pass a JSON object with key/value pair;
This JSON string object should be built in your Boomi process prior to using the “Set Property” shape, and use a dynamic value.
(on the screenshot, I’m using a static value)
Exemple of value :
{“foo”:“bar”,“baz”:“fubar”}
The result is the following :
your message is published with the standard headers + the foo=bar & baz=fubar headers.
Listen to Events & Get Headers in BOOMI
Connection
be sure to use
“Solace PubSub+ Platform - Partner connector”
Add a groovy 2.4 custom script ‘Data Process Shape’
Add the following code :
import java.util.Properties;
import java.io.InputStream;
import groovy.json.JsonSlurper;
import com.boomi.execution.ExecutionUtil;
logger = ExecutionUtil.getBaseLogger();
for( int i = 0; i < dataContext.getDataCount(); i++ )
{
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
Set<String> keys = props.stringPropertyNames();
String solaceUserProperties = null;
for(key in keys)
{
if(key.endsWith(".userProperties"))
{//Parsing JSON object representing userProperties and set it as individual DDP
solaceUserProperties = props.getProperty(key);
logger.info("Solace UserProperties found key='"+key+"', value='"+solaceUserProperties+"'");
def jsonSlurper = new JsonSlurper();
def object = jsonSlurper.parseText(solaceUserProperties);
Set<String> objectKeys = object.keySet();
for(key2 in objectKeys)
{
logger.info("Solace Properties found key='"+key+"', value='"+object.get(key2)+"'");
props.setProperty("document.dynamic.userdefined."+key2,object.get(key2));
}
}
else
{
logger.fine("Solace Other Properties found key='"+key+"', value='"+props.getProperty(key)+"'");
//ex: 'connector.track.solacetpp-VMLLNA-solace-prod.isElidingEligible', we just want the last part
String subKey = key.substring(key.lastIndexOf(".")+1);
props.setProperty("document.dynamic.userdefined.solace_"+subKey,props.getProperty(key));
}
}
logger.info(props.toString());
dataContext.storeStream(is, props);
}
This code will do the following :
- Add all headers as Dynamic Document Property under the name “solace__HEADER_KEY_”
- Parse userProperties json and add as Dynamic Document Property under the name “key”
Here are the list of standard headers:
key=‘connector.track.solacetpp-VMLLNA-solace-prod.senderTimestamp’, value=‘null’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.messageIDLong’, value=‘4’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.userProperties’, value=‘{“static_header_key”:“static_header_value_xyz”,“foo”:“bar”,“baz”:“fubar”}’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.dataType’, value=‘track’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.sourceType’, value=‘connector’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.redelivered’, value=‘false’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.cos’, value=‘0’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.type’, value=‘solacetpp-VMLLNA-solace-prod’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.priority’, value=‘4’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.timeToLive’, value=‘0’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.isReplyMessage’, value=‘false’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.isDMQEligible’, value=‘true’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.deliveryMode’, value=‘DIRECT’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.discardIndication’, value=‘false’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.messageID’, value=‘4’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.receiveTimestamp’, value=‘0’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.destination’, value=‘ride/request’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.expiration’, value=‘0’
key=‘connector.track.solacetpp-VMLLNA-solace-prod.isElidingEligible’, value=‘false’
Access headers as Dynamic Document Properties
To Acccess the “foo” userProperties :
To access the “destination” property :
Logging result
Hope this helps,
Thomas.
SMF Header Reference.xlsx (17.8 KB)