Author |
Message
|
zpat |
Posted: Wed Jun 04, 2014 2:41 am Post subject: RFE - ESQL access to user defined configurable services |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Please vote for this RFE to allow the useful feature of WMB/IIB User Defined configurable services to be accessible from ESQL (as well as from Java).
http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=54381 _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
Tibor |
Posted: Wed Jun 04, 2014 3:36 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
There was a related task for me recently, so I've clicked on the "Vote" button  |
|
Back to top |
|
 |
Esa |
Posted: Wed Jun 04, 2014 5:51 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
I have always written an ESQL wrapper for a little java CMP/MB/IIB API program for this purpose, but I agree that access from ESQL should be available out of the box. |
|
Back to top |
|
 |
zpat |
Posted: Wed Jun 04, 2014 6:34 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
In the interim - are you able to share that wrapper solution?
Also - when you code a workaround - it's a good idea to open a RFE to get it added to the product features. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
Esa |
Posted: Wed Jun 04, 2014 6:59 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Code: |
package mycompany.common;
import com.ibm.broker.config.proxy.BrokerProxy;
import com.ibm.broker.config.proxy.ConfigManagerProxyLoggedException;
import com.ibm.broker.config.proxy.ConfigManagerProxyPropertyNotInitializedException;
import com.ibm.broker.config.proxy.ConfigurableService;
import java.util.Properties;
public class BrokerFacade {
private static final String USERDEFINED = "UserDefined";
private static final String CMP_LOGGED_EXCEPTION = "BrokerFacede failed to connect to broker proxy";
private static final String CMP_PROP_NOT_INITIALIZED_EXCEPTION = "BrokerFacade failed to access configurable service";
private static final String PROPERTY_NOT_DEFINED = "BrokerFacade failed to get configurable property: ";
private static final String INTERRUPTED = "BrokerFacade got interrupted";
private BrokerProxy b;
private static final BrokerFacade INSTANCE = new BrokerFacade();
private static void initProxy() throws ConfigManagerProxyLoggedException,
InterruptedException {
{
synchronized (INSTANCE) {
if (null == INSTANCE.b) {
INSTANCE.b = BrokerProxy.getLocalInstance();
while (!INSTANCE.b.hasBeenPopulatedByBroker()) {
Thread.sleep(100);
}
}
}
}
}
public static String getUserDefinedConfigurableServiceProperty(
String configurableService, String property) {
try {
if (null == INSTANCE.b) {
initProxy();
}
ConfigurableService service = INSTANCE.b.getConfigurableService(
USERDEFINED, configurableService);
Properties props = service.getProperties();
String retval = (String) props.get(property);
if (null == retval) {
throw new RuntimeException(PROPERTY_NOT_DEFINED + property);
}
return retval;
} catch (ConfigManagerProxyLoggedException ex) {
throw new RuntimeException(CMP_LOGGED_EXCEPTION, ex);
} catch (ConfigManagerProxyPropertyNotInitializedException ex) {
throw new RuntimeException(CMP_PROP_NOT_INITIALIZED_EXCEPTION, ex);
} catch (InterruptedException ex) {
throw new RuntimeException(INTERRUPTED, ex);
}
}
}
|
Code: |
CREATE FUNCTION GetUserDefinedConfigurableServiceProperty(IN configurableService CHAR, IN property CHAR)
RETURNS CHAR
LANGUAGE JAVA
EXTERNAL NAME "mycompany.common.BrokerFacade.getUserDefinedConfigurableServiceProperty"
-- CLASSLOADER "MyCommonClassLoaderService"
; |
You should package the java code in a jar file and put it in shared classes on the broker machine.
edit: removed a line from the java code
Last edited by Esa on Wed Jun 04, 2014 11:43 am; edited 1 time in total |
|
Back to top |
|
 |
zpat |
Posted: Wed Jun 04, 2014 7:11 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Thanks _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
Tibor |
Posted: Wed Jun 04, 2014 7:15 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
A pretty good solution for BrokerProxy...  |
|
Back to top |
|
 |
sarath.g33 |
Posted: Mon Dec 05, 2016 7:53 am Post subject: |
|
|
Newbie
Joined: 12 Apr 2011 Posts: 8
|
Code: |
while (!INSTANCE.b.hasBeenPopulatedByBroker()) {
Thread.sleep(100);
}
|
Any advise why broker instance need to wait/sleep for 1 sec? In which scenarios it really used for waiting. Is it recommended by IBM?
Regards
Sarath |
|
Back to top |
|
 |
zpat |
Posted: Mon Dec 05, 2016 7:59 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
I think you will find it is 0.1 second (100 milliseconds).
I don't code Java but it looks like it is waiting if the broker proxy is not yet initialised. It won't always wait. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
cbruemmer |
Posted: Tue Jun 26, 2018 8:35 am Post subject: |
|
|
Newbie
Joined: 23 Aug 2017 Posts: 8
|
Hello all,
old thread, but...
I don't code Java either, but my opinion is, as the sleep is surrounded by a while, it is looping until forever.
Currently we see this error in the IIB (10.0.0.12) log: BIP2112E: Integration node internal error: diagnostic information 'Could not launch a handler for a local CMP connection', '0'.
And the Java code is not finishing and the flow hangs.
Any ideas?
Thanks in advance
Christian |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jun 26, 2018 9:54 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
cbruemmer wrote: |
Hello all,
old thread, but...
I don't code Java either, but my opinion is, as the sleep is surrounded by a while, it is looping until forever.
Currently we see this error in the IIB (10.0.0.12) log: BIP2112E: Integration node internal error: diagnostic information 'Could not launch a handler for a local CMP connection', '0'.
And the Java code is not finishing and the flow hangs.
Any ideas?
Thanks in advance
Christian |
It is definitely coded for the happy path and never looks at what happens if the instance is never populated by the broker...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Esa |
Posted: Tue Jun 26, 2018 11:11 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Interesting...
My assumption was that if you run this form a message flow, surely the broker (node) must be up and running. Node not being able to launch a handler for local connection is something new. V 10 may be connecting in some new way under the hoods. I will take a look.
Feel free to add a timeout or counter that would terminate the loop and throw an exception after a while. Always a good idea.
Just to make sure, you are calling the code from a compute or java compute node, not from outside the node like from a Jenkins project, aren't you? |
|
Back to top |
|
 |
cbruemmer |
Posted: Wed Jun 27, 2018 12:42 am Post subject: |
|
|
Newbie
Joined: 23 Aug 2017 Posts: 8
|
Hello Esa,
yes only from a compute or java compute node, but (maybe that is something new) from a shared library.
So especially after deploying the shared library I can nearly reproduce the error on the fly, because a lot of Apps, Svcs and Apis are restarted.
I've added a counter - so at least the flows are not longer blocking.
Best regards
Christian |
|
Back to top |
|
 |
Esa |
Posted: Wed Jun 27, 2018 1:26 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
cbruemmer wrote: |
So especially after deploying the shared library I can nearly reproduce the error on the fly, because a lot of Apps, Svcs and Apis are restarted.
|
OK, that may explain some of it. You see, the class is a Singleton, which means that it is running on one instance that is shared across the whole integration server. The code block is synchronized over INSTANCE, and only one thread should be trying to connect. After it has connected, all other threads should -- one at the time -- find out that INSTANCE.b is already populated and not start looping at all. Maybe something goes wrong here. |
|
Back to top |
|
 |
timber |
Posted: Wed Jun 27, 2018 1:38 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Unless you take to avoid it, a Java singleton is scoped to a particular classloader. If the same class is loaded in two or more classloaders, you will get one instance of the 'singleton' per classloader.
Not making any assumptions about this particular case, but that's definitely one possibility to consider. Try printing the classloader id of each instance to the console and see whether they're all the same. |
|
Back to top |
|
 |
|