Try PubSub+

BOOMI : Publish Events to PubSub+ with custom headers

Thomas MansonThomas Manson Member, Employee Posts: 7 Solace Employee

I just wanted to share how to set specific headers when publishing events with 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.

Hope this helps,
Thomas.

Comments

  • marcmarc Member, Administrator, Moderator, Employee Posts: 469 admin

    Awesome, thanks for sharing @Thomas Manson 🙏

  • noeljoaquinnoeljoaquin Member Posts: 2

    Hi Thomas, thanks for sharing this! I noticed this changes yesterday on the connector operation and began to play with it.
    I've tried putting in some properties in there, setting them as Dynamic Document Property/Dynamic Process Property/Static value, etc.
    Unfortunately, none of them work (even the static key/value pairs), I wasn't able to access it on the Boomi Listener process. How do you access those values on the Boomi Listener process?

  • Thomas MansonThomas Manson Member, Employee Posts: 7 Solace Employee

    Hi Noel,

    I'll share you how to do that this week !

    I've used Spring Cloud Stream code to get the events header and check that it works when you're publishing it with Boomi.

    On the listen part, there's a limitation in Boomi's SDK, that doesn't make it easy to get the headers.
    But I'll share how to do that later this week.

    Thomas.

  • noeljoaquinnoeljoaquin Member Posts: 2

    Hi Thomas,

    I have spoken to Andrew Mackenzie last week and he mentioned that those key/value pairs are also added to the Solace branded connector's document property 'User Properties' together with other key/value pairs we set on the same property through the set properties shape.

    With this, I was able to retrieve the properties already on the listener part (getting from the Solace branded connector's document property "User Properties"). I've written a short script to parse and re-assign these key/value pairs back to be able to use them.

    Thanks so much!

  • Thomas MansonThomas Manson Member, Employee Posts: 7 Solace Employee
    edited July 21 #6

    Hi Noel,

    This kind of script (Groovy 2.4) on a "Data Process Shape"/"Custom Scripting".
    I'll document it more explicitly later

    import java.util.Properties;
    import java.io.InputStream;
    import groovy.json.JsonSlurper;
    
    for( int i = 0; i < dataContext.getDataCount(); i++ ) 
    {
        InputStream is    = dataContext.getStream(i);
        Properties  props = dataContext.getProperties(i);
    
        def jsonSlurper = new JsonSlurper();
        def object = jsonSlurper.parseText(props.getProperty("document.dynamic.userdefined.ddpUserPropertiesJSON"));
    
    //  foo, baz, static_header_key - these are the three values being passed as JSON keys in the
    //  Solace Connector userProperties JSON string.
    
    //  foo, baz, static_header_key- these are the three DDPs created in the receiving
    //  Boomi Process with  values set to the corresponding values from the user propertie JSON.  Note that
    //  these DDPs are created here and do not need to be created ahead of time.
    //  The developer needs to know the JSON keys coming in in this code.
    
        props.setProperty("document.dynamic.userdefined.foo",object.foo);
        props.setProperty("document.dynamic.userdefined.baz",object.baz);
        props.setProperty("document.dynamic.userdefined.static_header_key",object.static_header_key);
    
        dataContext.storeStream(is, props);
    }
    
Sign In or Register to comment.