Hi Andy,
Here's some example code showing an example of what we talked through quickly on the call:
// optionally copy message headers
copyMessageHeaders(inMessage, outMessage);
// ----------------------------------------------------------
// Add user code below
MbElement outRoot = outMessage.getRootElement();
MbElement outBody = outRoot.createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbPolicy myPol = getPolicy("UserDefined","{MyUserDefinedPolicyProject}:MyUserDefinedPolicy");
MbElement PolicyInformation = outBody.createElementAsFirstChild(MbElement.TYPE_NAME,"PolicyInformation",null);
PolicyInformation.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"UserDefinedPolicyName",myPol.getName());
PolicyInformation.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"UserDefinedPolicyTypeName",myPol.getType());
PolicyInformation.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"UserDefinedPolicyTypeName",myPol.getPropertyValueAsString("Property1"));
PolicyInformation.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"UserDefinedPolicyTypeName",myPol.getPropertyValueAsString("Property2"));
PolicyInformation.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"UserDefinedPolicyTypeName",myPol.getPropertyValueAsString("Property3"));
// End of user code
// ----------------------------------------------------------
This code would work in conjunction with a user defined policy like this:
<?xml version="1.0" encoding="UTF-8"?>
<policies>
<policy policyType="UserDefined" policyName="MyUserDefinedPolicy" policyTemplate="User Defined Template">
<Property1>Tottenham Hotspur</Property1>
<Property2>Middlesbrough</Property2>
<Property3>Werder Bremen</Property3>
</policy>
</policies>
The code would generate an output message like this:
<PolicyInformation>
<UserDefinedPolicyName>MyUserDefinedPolicy</UserDefinedPolicyName>
<UserDefinedPolicyTypeName>UserDefined</UserDefinedPolicyTypeName>
<UserDefinedPolicyTypeName>Tottenham Hotspur</UserDefinedPolicyTypeName>
<UserDefinedPolicyTypeName>Middlesbrough</UserDefinedPolicyTypeName>
<UserDefinedPolicyTypeName>Werder Bremen</UserDefinedPolicyTypeName>
</PolicyInformation>
Unfortunately there's one other small gotcha that we should add ... the jplugin2.jar file which is supplied as part of the v11 Toolkit installation unfortunately doesn't have the methods available as we inadvertently didn't update this jar when shipping the product. However, the correct jar has been built into the runtime. This means that you have a small workaround which must be applied. When you create your Java Compute node project, the Java build Path will be set up to reference the jplugin2.jar file in a directory such as:
C:\Program Files\IBM\ACE\11.0.0.1\tools\plugins\com.ibm.etools.mft.jcn_11.0.0.1\jplugin2.jar
You will need to change this to refer to the jplugin2 which is in the runtime's server classes folder:
C:\Program Files\IBM\ACE\11.0.0.1\server\classes\jplugin2.jar
Cheers,
Ben
------------------------------
Ben Thompson
IBM UK
------------------------------
Original Message:
Sent: 11-20-2018 12:28
From: Andy Mao
Subject: AMA technical Q&A coming up
How to get user defined policy in java or esql compute node while integration node is not used in ACE11?
In 11.0.0.2 we reintroduced the concept of the integration node. There is now a getPolicy method which allows you to look up any policy in a Java Compute node.
Above was my question posted in the tech session and the answer provided by your team.
However, I am not able to find getPolicy method in MbNode class, can you please provide some of the code sample to get the user defined policies? The installed version of ACE is v10.0.0.2.
Thanks
------------------------------
Andy Mao
Original Message:
Sent: 11-06-2018 17:22
From: Amy McCormick
Subject: AMA technical Q&A coming up
The next "Ask Me Anything: App Connect Enterprise - Technical Q&A" session is coming up on November 20th. We will have a table of subject matter experts on the line to address your questions - come prepared!
Feel free to submit any questions for discussion in this thread and don't forget to register to attend the event live: https://event.on24.com/wcc/r/1860387/26AE5C66DE7BB64FCAE86707265FD140.
------------------------------
Amy McCormick
Offering Manager
IBM App Connect Enterprise, IBM App Connect service (Enterprise plans)
IBM Integration Bus, IBM Integration Bus on Cloud, IIB industry packs
------------------------------