Statement of Work (DRAFT)
TAFC CALLJEE
And
Message Driven Beans
Version No.
2.0
Version Date
21 November 2013
TAFC CALLJEE
Document Owner This document is subject to change control. Each change must be agreed, annotated and signed by the owners of the document listed below: The owners of this document are listed below:
TEMENOS
Helpdesk Manager
Sriraman Ganesan
Revision History Version
Revision Date
Revision Description
Author
1.0
12 Apr 2010
TAFC CALLJEE and MDBs
Sheryl Rahman
1.1
21 Nov 2013
Updated with CALLJEE HA changes and error codes
Sheryl Rahman
Sign Off History Version
Date
TEMENOS Authorization
Client Authorization
1.0
Message Driven Beans
2010-04-12
TAFC CALLJEE
Introduction This document aims to explain how to deploy Message Driven Beans (MDBs), a special type of Enterprise Java Beans (EJBs) which utilizes the inbound connection feature of the TAFC Resource Adapter. It can be invoked from a jBC program using the CALLJEE or JEEActivate functions and enables T24 applications to place messages on JMS queues. These remote calls are achieved by using a TCP/IP connection from the TAFC process to a Java Enterprise Edition Application Server – such as JBoss. The only configuration necessary in TAFC is a host and a port.
Message Driven Beans
2010-04-12
TAFC CALLJEE
Deploying a Simple Bean JBoss has three deployment descriptors for declaring the deployment properties for enterprise beans:
ejb-jar.xml - This is the standard EJB deployment descriptor, declaring the available enterprise beans, their logical names, interfaces, and other deployment properties (security, transactions, etc.). jboss.xml - This optional file is used to specify a different JNDI name for a bean's home interface. The default JNDI name for a bean is the ejb-jar.xml ejb-name element value. jaws.xml - This file is necessary only for CMP entity bean deployment.
We are concerned with only the ejb-jar.xml and jboss.xml files.
Deployment Process
Ultimately, enterprise beans are packaged in a JAR file with the appropriate XML files in the META-INF folder. Most J2EE app servers require the deployment of an EJB JAR within a WAR file, and even within an EAR file. The process of packaging up an enterprise bean with deployment descriptors into a larger archive with its deployment descriptors can become rather complex. This process may be necessary in a production environment, but in development, you need quick, efficient deployment. JBoss provides the best of both worlds. All you do to deploy EJBs in JBoss is drop the archive into the deploy directory. The JBoss engine immediately inspects the contents of the archive and attempts to deploy the bean(s). Undeploying is as easy as deleting the archive from the deploy directory. To access the bean so created we will have to write the client code. Let us try to understand this using a simple example. Our T24 program will communicate to the MDB that prints a message to standard output and returns an ‘All OK’ response to the basic program if everything goes well. CALLJEE is the TAFC statement that we use to invoke EJB from our T24 basic routine/ program.
Message Driven Beans
2010-04-12
TAFC CALLJEE
Enhanced high availability for JEE inbound connections The jBC CALLJEE statement enables application developers to send messages to the application server and therefore provide connectivity to other systems. The environment variables • •
JREMOTE_INBOUND_HOST=
JREMOTE_INBOUND_PORT=
Used to connect to the JEE application server are still supported for backwards compatibility. In order to provide connectivity and failover to secondary servers, application developers were required to use the JEEOpen/JEEActivate/JEEClose statements, manage connection handles and optionally provide a retry mechanism for failover. New environment variables • •
JEE_HOSTS=, , ... JEE_PORTS=, , ...
are now available to provide the jBC CALLJEE statement with connectivity to multiple servers. This mechanism Does NOT load balance requests between multiple servers. CALLJEE establishes only one connection to a single application server. CALLJEE always attempts to first establish a connection to host 1 if available, otherwise to host2, and so on. CALLJEE does not fail-over at runtime – a JBC application needs to provide the retry mechanism, i.e. re-send the request in case of failure. See CALLJEE error codes for identifying connection errors. Enhanced high availability for JEE inbound connections The inbound listener now uses the TOCF framework library (tocfframework.jar) which provides an enhanced event pipeline based on the Netty serialization library. Note: The Netty library - included in TOCF(EE) pack (R12.0.0.2 onwards) - must be made available to the application server’s system classloader in case the application server does not already ship this library. This is only required when enabling the inbound listener.
Message Driven Beans
2010-04-12
TAFC CALLJEE
Make sure you have the attached netty library inside \lib location. For eg: D:\R12.GA.ModelBank.Win64.SCU\Temenos\ModelBankR12\3rdParty\jboss\server\default\lib Ensure “inbound listener” is configured inside the resource adapter (tocfT24rara.rar). Enable the port as shown below: com.temenos.tocf.t24ra.T24ResourceAdapter Inbound listener server name (empty = bind to all addresses) listenHost java.lang.String 10.92.7.91 --> Inbound listener port number (0 = inbound listener disabled) listenPort java.lang.Integer 55006 CALLJEE Error Codes
0 1 2 3 4 101 102
Action successful Connection error (i.e. connection error between T24 and App server) Transaction error (i.e. transaction related error) Error attempting to close a connection while a transaction is active Activation error (i.e. endpoint is not activated or is unable to process request) Invalid host Invalid port
Message Driven Beans
2010-04-12
TAFC CALLJEE
The Programs PROGRAM TEST_PRINT_MESSAGE INCLUDE JBC.h TRANSTART ELSE CRT "Unable to start the transaction." ACTIVATION = "PRINTMESSAGE" INFO = "Hello folks!" ERROR.CODE = CALLJEE (ACTIVATION,INFO) CRT ERROR.CODE CRT "response received: >>>>":INFO:"<<<<" TRANSEND ELSE CRT "Unabel to commit the transaction."
In order to be callable, a message driven bean must implement the JRemoteMessageListener interface and activate the JRemote JCA (jremote-ra.rar). Once activated the JRemote JCA will listen for incoming requests on the configured IP address and port (see the ra.xml inside jremote-ra.rar). package com.jbase.mytutorial.mdb; import com.jbase.jremote.JDynArray; import com.jbase.jremote.jca.inflow.JRemoteMessageListener; import java.io.PrintStream; import java.lang.reflect.Method; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJBException; import javax.naming.NamingException; import javax.resource.ResourceException; import javax.ejb.MessageDrivenBean; import javax.ejb.MessageDrivenContext; import javax.naming.InitialContext;
public class myMessageBean implements MessageDrivenBean, JRemoteMessageListener { private static final Logger logger = Logger.getLogger(myMessageBean.class.getName()); private InitialContext _context; public myMessageBean(){ this._context=null; } public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException{ }
Message Driven Beans
2010-04-12
TAFC CALLJEE
public void ejbCreate() throws EJBException{ try{ this._context= new InitialContext(); } catch (NamingException e){ logger.log(Level.SEVERE,"Failed to create initial context",e); } } public void ejbRemove() {} public JDynArray onMessage(JDynArray myArray){ logger.info("incoming message [" + myArray + "]"); if(this._context!=null){ String myMessage=myArray.get(1); System.out.println("myMessageBean confirming the receipt of the following message:\n" + ">>>>"+ myMessage +"<<<<"); return new JDynArray("All is well"); } else{ return new JDynArray("ERROR"); } } public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException {} public void afterDelivery() throws ResourceException {} public void release() {} }
Dissection of myMessageBean.java The MDB class must implement the javax.jms.MessageListener [or use the Temenos supplied JRemoteMessageListener] and the javax.ejb.MessageDrivenBean interfaces. In addition to the onMessage method, the following must be implemented:
A public constructor with no argument. public void ejbCreate(): with no arguments, called at the bean instantiation time. It may be used to allocate some resources, such as connection factories, for example if the bean sends messages, or datasources or if the bean accesses databases. public void ejbRemove(): usually used to free the resources allocated in the ejbCreate method. public void setMessageDrivenContext(MessageDrivenContext mdc): called by the container after the instance creation, with no transaction context. The JOnAS container provides the bean with a container context that can be used for transaction management, e.g., for calling setRollbackOnly(), getRollbackOnly(), getUserTransaction().
Message Driven Beans
2010-04-12
TAFC CALLJEE
The onMessage method is activated on receipt of messages sent by a client application to the corresponding JMS destination. public JDynArray onMessage(JDynArray myArray){ logger.info("incoming message [" + myArray + "]"); if(this._context!=null){ String myMessage=myArray.get(1); System.out.println("myMessageBean confirming the receipt of the following message:\n" + ">>>>"+ myMessage +"<<<<"); return new JDynArray("All is well"); } else{ return new JDynArray("ERROR"); }
} The JDynArray is a jBASE type that implements a dynamic string array where attribute, value, and subvalue delimiters mark the array indices. On successful creation of a transactional context and arrival of a message thereafter, the method returns a response of type jDynArray to the caller.
Deployment descriptors Jboss.xml:
-
Change ejb-name to something identifiable. Resource adapter must be jremote-ra.rar. That contains ra.xml with listening port no (55006) for jRemoteResourceAdapter
PrintMessageMDBJRemote jremote-ra.rar jboss.jca:service=RARDeployment,name='jremote-ra.rar'
Message Driven Beans
2010-04-12
TAFC CALLJEE
Ejb-jar.xml:
Multiple instances of the MDBs can be created in the ejb-jar.xml to receive requests for different activation types. The jBC program can determine which MDB instance it needs to call by the ACTIVATION string. The ACTIVATION string that we use in our test program is “PRINTMESSAGE” – specify it under the tag. The other thing that needs to be taken care here is the ejb-name (matched in jboss.xml).
JMS Dispatcher PrintMessageMDB JRemote PrintMessageMDBJRemote com.jbase.mytutorial.mdb.myMessageBean com.jbase.jremote.jca.inflow.JRemoteMessageListener Container handler PRINTMESSAGE
Message Driven Beans
2010-04-12
TAFC CALLJEE
OUTPUTS JBOSS Console - during deployment:
Run the T24 program:
JBOSS Console – When TEST.PRINT.MESSAGE is run:
Message Driven Beans
2010-04-12
TAFC CALLJEE
References Temenos knowledge base http://knowledgebase.temenosgroup.com/ Java JDK http://java.sun.com J2EE Connector Architecture (JCA) Specification http://java.sun.com/j2ee/connector/ JBoss http://www.jboss.org/ JBoss JTA Programmers guide http://labs.jboss.com/jbosstm/docs/4.2.3/manuals/html/jta/ProgrammersGuide.html
Message Driven Beans
2010-04-12