Showing posts with label Configurable Properties. Show all posts
Showing posts with label Configurable Properties. Show all posts

Tuesday, 12 February 2019

Accessing a User Defined Configurable Service in Java

A UserDefined configurable service is accessible by the JavaCompute Node node only, and cannot be accessed by ESQL.

I created a UserDefined configurable service with the following values:

EmployeeDetails
EmployeeNumber:  O0001
EmployeeName:  James Ndlovu
Department:  IT
City: Johannesburg


In the LocalEnvironment set the EmployeeNUmber in Variables/EmployeeNumber which I want to use to retrive the Employee Details from the config service.

To create the Java code, right-click the JavaCompute node and click Open Java to create and open a Java™ file in the Editor view.
Create the Java class for the node in which you want to include IBM Integration API methods.
Add the IBM Integration API JAR file install_dir/common/classes/IntegrationAPI.jar to the Java build path for the associated Java project.

Import com.ibm.broker.config.proxy.* in your code.


try { // create new message as a copy of the input MbMessage outMessage = new           MbMessage(inMessage); outAssembly = new MbMessageAssembly(inAssembly, outMessage); /*get   employee details from local environment variable */
 MbMessage localEnv = inAssembly.getLocalEnvironment(); 
 MbElement empNoVar =     localEnv.getRootElement().getFirstElementByPath("Variables/EmployeeNumber"); 
 String employeeNumber = empNoVar.getValueAsString(); 
 BrokerProxy b = BrokerProxy.getLocalInstance(); /*return an instance of the BrokerProxy object for the integration node to which the message flow (that contains this node) is deployed */
 while (!b.hasBeenPopulatedByBroker()) 
 { 
   Thread.sleep(100); /*This ensures that the BrokerProxy object is populated with data from the integration node before you access the configurable service */
 } 
 ConfigurableService vendorUDCS = b.getConfigurableService("UserDefined", "EmployeeDetails"); 
 String employeeDetails = vendorUDCS.getProperties().getProperty(employeeNumber); /*output the employeeDetails to a local environment variable*/
 MbMessage newEnv = new MbMessage(localEnv); newEnv.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "EmpDetails", employeeDetails); 
 outAssembly = new MbMessageAssembly(inAssembly, newEnv, inAssembly.getExceptionList(), inAssembly.getMessage()); 
b.disconnect();

catch (MbException e) 
{ // Re-throw to allow Broker handling of MbException throw e; }

Thursday, 1 November 2018

Editing configurable properties in a BAR file with MQSIAPPLYBAROVERRIDE

A bar file's configurable properties can be customized without editing and rebuilding the message flows or the resources that they use.

This can be achieved in the following ways:

  1. Editing configurable properties with the IBM Integration Toolkit.
  2. Editing configurable properties with the mqsiapplybaroverride command

In this post I will concentrate on editing the configurable properties using the mqsiapplybaroverride command.

1. Use the mqsireadbar command to determine which propertes can be configured.

mqsireadbar -b <barfile> -r

e.g. mqsireadbar -b c:\myBarFile.bar -r

The above command will display the properties on the screen.

2. Use the mqsiapplybaroverride to change the properties

Command Syntax
 mqsiapplybaroverride -b barFileName [-p overridesFile] [-m manualOverrides] [-k applicationName] [-y libraryName] [-r] [-o outputFile] [-v traceFileName] 

Command options: 
 '-b barFileName' - The name of the BAR file (in zip format) to be overridden.
 '-p overridesFile' - The file name of the plain text file that contains one of these items: the integration node properties to be overwritten, the entire new deployment descriptor, or a BAR file that contains the entire new deployment descriptor.
 '-m manualOverrides' -  A comma separated list of key=value pairs that describe the overrides to apply. On Windows systems, the list must be enclosed in quotation marks (""). If used in conjunction with -p, the overrides that are specified with the -m parameter are performed after all overrides that are specified by the -p parameter have been made.
 '-k applicationName' - The name of the application to which the overrides will be applied.
 '-y libraryName' - The name of the static library or shared library to which the overrides will be applied.
 '-r' - requests that overrides are applied recursively through applications and libraries.
 '-o outputFile' - The name of the output bar file to which the bar file changes are to be made. If this name is not specified, the input file is overwritten.
 '-v traceFileName' - Verbose internal trace is sent to the specified file.
 Note: Overrides must be supplied either in the form FLOW#NODE.PROPERTY=NEWVALUE or in the form OLDVALUE=NEWVALUE. If the latter form is used, OLDVALUE must already be an overridden value in the deployment descriptor. Specify FLOW#NODE.PROPERTY on its own to remove an override.

Create a text file, and list the properties that you want to change in the following format:
property=newValue.

mqsiapplybaroverride -b <barfile> -p <overridesFile> -k <application name>

Spefify output file parameter if you dont want the bar file to be overwritten.

mqsiapplybaroverride -b c:\temp\test.bar -p c:\temp\BarFileOverride.txt -k c:\temp\test.bar

Alternatively instead of using the command console, the bar file can be overridden by using the overrides file in the web console by clicking the Overrides button and selecting the overrides file.

N.B - the user running this command should be an administrator of the machine.

Wednesday, 19 September 2018

Accessing a Configurable Service using Java

The configurable service is a readily available to keep data that an integration message flow may need at runtime.

1.Create a User Defined Configurable Service using the web console and populate it.



2. The UserDefined Configurable Cervice properties can only be accessed using a JavaCompute node.

Import com.ibm.broker.config.proxy.* in your code.
  import com.ibm.broker.config.proxy.*; 

BrokerProxy b = BrokerProxy.getLocalInstance(); 
while(!b.hasBeenPopulatedByBroker())
{
   Thread.sleep(100); 
}
ConfigurableService vendorUDCS = b.getConfigurableService("UserDefined", "MyConfigService"); 
String vendorMQDetails  = vendorUDCS.getProperties().getProperty("server");


This method below will return an instance of the BrokerProxy object for the integration node to which the message flow is deployed.
BrokerProxy b = BrokerProxy.getLocalInstance();

 To ensure that the BrokerProxy object has been populated with data from the broker
  before we access the configurable service, Add the following code:
while(!b.hasBeenPopulatedByBroker()) {
   Thread.sleep(100); 
}

The statement below will return a User Defined Configurable service called 'MyConfigService' ConfigurableService vendorUDCS = b.getConfigurableService("UserDefined", "MyConfigService");

You maybe interested in this post: Accessing a User Defined Configurable Service in Java