Can custom Registered Functions be added without modifying PubSubPlus Transformer itself?

TomC
TomC Member Posts: 9 ✭✭

The pubsubplus-processor-message-transformer-1.2.2-User-Guide.pdf document outlines how user configured header transforms can be achieved using Spel Expressions.

It also outlines how these Spel Expressions can use Registered Functions (plural) but then lists one function 'isPayloadBytes()' as a built-in function.

My questions:

  • is it possible to register new custom functions for use in Spel expressions for header transforms?
  • given that pubsubplus transformer is a packaged product, can custom functions be registered in new code external to the transformer and if so, how ?

Tagged:

Best Answer

  • amackenzie
    amackenzie Member, Employee Posts: 269 Solace Employee
    #2 Answer ✓

    You can't register the function like isPayloadBytes however, you can put your static class(es) on the classpath (like in the /libs folder) and then call it with

    T(package.customClass).customFunction()

Answers

  • TomC
    TomC Member Posts: 9 ✭✭

    Would be great to get a response. Or is this a 'dead' product?

  • amackenzie
    amackenzie Member, Employee Posts: 269 Solace Employee

    Hi, I am looking into this for you with our dev team. While it is possible to put a JAR on your classpath with the method you want to call, we do take steps to prevent arbitrary code execution as this os a security risk.

    I should also mention that in the next few months we will be migrating away from the transform payload configuration to something more powerful that allows for header, payload, and custom funtions to participate in transforming/mapping source to target in the connectors.

    Therefore, the solution you are looking at will continue to work, but will be deprecated over time for the new solution.

  • TomC
    TomC Member Posts: 9 ✭✭

    Thanks for the response Andrew.

    Yes, there are two (external) items that have to be put on the classpath - a hash function definition and a code snippet which registers this function with the SpEL environment, so that it can be subsequently used in a SpEL expression.

    The dilemma is: How to get the transformer to pick up the (external) code that registers the custom function with SpEL?

    I thought about using Spring annotations e.g. @Component because these are scanned at run-time but not having much luck with it. Should this work and if so how? If not, is there another solution/approach?

    Thanks.

  • amackenzie
    amackenzie Member, Employee Posts: 269 Solace Employee
    #6 Answer ✓

    You can't register the function like isPayloadBytes however, you can put your static class(es) on the classpath (like in the /libs folder) and then call it with

    T(package.customClass).customFunction()

  • TomC
    TomC Member Posts: 9 ✭✭

    That works. Thanks for following that up Andrew.

    Perhaps this would be a good addition to the User Guide. The UG led me to the assumption that the way to call a custom function was using a Registered Function.