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; }

Friday, 25 January 2019

Creating WebSphere MQ Objects

Below are some commands for creating mq objects.
Use the DEFINE QLOCAL to create a local queue
DEFINE QLOCAL ('myqueue') +
       DESCR('my test queue') +
       PUT(ENABLED) +
       DEFPRTY(0) +
       DEFPSIST(YES) +
       DEFPRESP(SYNC) +
       SCOPE(QMGR) +
       GET(ENABLED) +
       PROPCTL(COMPAT) +
       DEFREADA(NO) +
       MAXDEPTH(999999999) +
       CLUSTER(' ') +
       CLUSNL(' ') +
       DEFBIND(OPEN) +
       CLWLRANK(0) +
       CLWLPRTY(0) +
       CUSTOM('capexpry(25920000)') +
       REPLACE

Use the DEFINE QALIAS to create an alias queue
DEFINE QALIAS ('myaliasq') +
DESCR('My alias queue') +
PUT(ENABLED) +
  DEFPSIST(YES) +
SCOPE(QMGR) +
        GET(ENABLED) +
TARGET ('REMOTE QUEUE')

Use the DEFINE QREMOTE to create a remote queue
DEFINE QREMOTE (REMOTE QUEUE) +
DESCR ('Remote Queue') +
RNAME (REMOTE QUEUE) +
RQMNAME (QMGR1) +
XMITQ (XMIT1)

You can save the commands in a text file.
Use the runmqsc command to issue MQSC commands to a queue manager.

runmqsc QMGR  <  C:\Temp\MQ_Objects.txt > C:\Temp\result.txt

The above command will invoke the MQSC commands in the text file against the QMGR queue manager. The result is sent to result.txt.

From WebSphere MQ veriosn 8.0.0.4, a new attribute CAPEXPRY has been introduced that can be used to alleviate problems of messages building up and hitting maximum depth limits. Setting this attribute on a destination means that when a message is put to that destination, the expiry time of the message will be limited to the value set in CAPEXPRY.