ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Basic question on JCNs

Post new topic  Reply to topic
 Basic question on JCNs « View previous topic :: View next topic » 
Author Message
petervh1
PostPosted: Wed Mar 02, 2022 2:30 am    Post subject: Basic question on JCNs Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 123

Hi

Can anyone please point me to a sample/discussion on how to use a JCN to implement classes that are not associated with the 4 templates that are supplied with the Java Compute Node Class Template wizard.

What I want to do is use a class that sets up an Athena client, submits a query to Athena, retrieves the result and then processes the result.

My (basic) understanding of setting up a JCN is that you need to select a template for the wizard, which then sets up something like this (I've used the Create new message template option):

Code:
public class Client_access_JavaCompute extends MbJavaComputeNode {

   public void evaluate(MbMessageAssembly contact admin) throws MbException {
      MbOutputTerminal out = getOutputTerminal("out");
      MbOutputTerminal alt = getOutputTerminal("alternate");
.
.
.


I've tried replacing the Java code with the following:

Code:

public abstract class Client_access_JavaCompute extends MbJavaComputeNode {
     public static void main(String[] args) throws InterruptedException
     {
         // Build an AmazonAthena client
         AthenaClientFactory factory = new AthenaClientFactory();
         AmazonAthena athenaClient = factory.createClient();

         String queryExecutionId = submitAthenaQuery(athenaClient);

         waitForQueryToComplete(athenaClient, queryExecutionId);

         processResultRows(athenaClient, queryExecutionId);
     }
.
.
.


but I get a deployment error:

Code:

BIP4517E: An exception was issued when an instance of Java class xxx was being created for JCN yyy. The stack trace of the exception is:
'Frame: 0 java.lang.InstantiationException:




I need to find some guidance on where and how to replace this with the Java code that sets up the Athena client.

Thanks
Back to top
View user's profile Send private message
abhi_thri
PostPosted: Wed Mar 02, 2022 3:09 am    Post subject: Reply with quote

Knight

Joined: 17 Jul 2017
Posts: 516
Location: UK

hi...you can write the java code within the evaluate method itself,

https://www.ibm.com/docs/en/app-connect/11.0.0?topic=java-interacting-databases-by-using-javacompute-node

https://www.ibm.com/docs/en/app-connect/11.0.0?topic=java-calling-enterprise-bean

Also, any one time tasks could be done within onInitialize() method,

https://www.ibm.com/docs/en/app-connect/11.0.0?topic=wj-accessing-message-flow-user-defined-properties-from-javacompute-node

Alternatively, if an external Athena java client program alreadys exists you could call its methods directly from ESQL itself which saves the trouble of doing all the connection managment, exception handling etc...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Basic question on JCNs
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.