JCAPSMentor - Java CAPS Unleashed - Basic to Expert Discussions

JCAPSMentor - Basic to Expert Discussions Jcaps, SOA, SUN, Netbeans, Enterprise, Sun System Application Server, Java, J2EE, EAI, JBI, Composite Application Platform Suite, EDI, SeeBeyond, HL7, Singapore

 
  FOLLOW US!
  JCAPSMentor

Visit us at Facebook



 

  Visitors LIVE! Stats
 
  Covering the World!
 
Asynchronous call in JCAPS BPEL (JCD)
The java.util.concurrent.ExecutorService interface represents an asynchronous execution mechanism which is capable of executing tasks in the background of a BPEL transaction. 

An ExecutorService is thus very similar to a thread pool. In fact, the implementation of ExecutorService present in the java.util.concurrentpackage is a thread pool implementation.

The below code could be incorporated into JCD (Java Collaboration Definition) to achieve concurrency in JCAPS - BPEL:

 /**
     * JCD Code: Asynchronous call to invoke any method
     * * *
     * @author Manesh Abhimanyu
     * @param String Input 1
     * @param String Input 2
     */
    public void asyncServiceMethod( final String input1, final String input2)
    {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        try {
            Runnable task = new Runnable(){
                public void run()
                {
                    try {
                        invokeJCAPSMentor( input1, input2 );
                    } catch ( Exception ex ) {
                          // handle error which cannot be thrown back
                    }
                }
            };
            executor.execute( task );
        } catch ( Exception e ) {
            // handle error which cannot be thrown back
        }  finally {
            // gargabe collect
            executor.shutdown();
        }
    }






More reading:
Service Execute API


Author: Manesh Abhimanyu.

Labels: , , , , , , ,

 
Java CAPS Best Practices
1. Architecture: Layered architecture is used to make services loosely coupled and most interactions occur only between neighboring layers in a distributed network. The layers include receiving layer, mapping layer, delivery layer and services layer.

Receiving Layer: Receives data from an INBOUND external system

Mapping Layer: Transforms the input message in to required output format. All validations, business rules are applied in this layer

Delivery Layer: Delivery layer sends data to OUTBOUND external system

Services Layer: A layer used to process interface alerts, logs and errors to a common database

Any changes to business requirements (code) will affect the mapping layer alone where the business transformations are implemented. Also during the runtime, services can be deployed depending on the location of external systems.


2. Reusable Web Services: Functional re-usability is preferred over code re-usability. Common business functions can be converted in to reusable web services. Ex: We can have re-usable services for some of the common functions like FTP’eing files, Sending/Receiving IDOCs to/from SAP etc, Sending emails to stake holders.


3. Data Streaming: Streaming is used to process files with large sizes. This will avoid any performance degradation while transforming large files. While processing large data coming from database/file (multiple XML/IDOC records), it is better to process one record at a time. Processing the complete data at once will pose performance issues and also require more system resources.


4. Variables & Constants: Using project or environment variables/constants provide flexibility to deploy projects/environments between environments. The project or environment variables/constants defined can be used as multitude of fields in project components (connectivity map) and environment components (Integration Server, IQ Manager, External Systems etc). This makes easy for deploying projects on multiple environments and only environment variables will be changed from one environment to other and there is no need to change the configurations on project connectivity maps.


5. Distributed Runtime Deployment: Services can be deployed based on the location of end systems. This will avoid any network traffic/failures between external systems and eGate system. In case of connection failures to external systems all the messages are queued in the JMS queues and processed after they become operational.


6. Common Services Framework (CSF): This is used to send alert, logging and error notifications to a common database. The data will be used to alert teams with emails in case of data or connection failures. The framework will automatically captures required information (project name, service name etc) to send alert, log and error details to CSF database. This can also be extended by having services like sending alerts to technical teams etc. Each of these services can be created as self contained projects and deployed in a distributed network.


7. Self contained project: Most of the times, projects have dependencies with some common project services (that contains re-usable JCDs etc). But wherever applicable, it is suggested to avoid dependencies/references on/to other projects/sub-projects. This makes code deployments simple. This is not going to have any impact on the runtime performance.


8. Reusable JARs: It is suggested to use reusable JAR files for common methods/functions which are reused across the projects ex: Date/String manipulations, Number/Date Validations etc. This will also increase the runtime performance of the interfaces.


9. Property Files: Using property files will make deployments easy between environments. Ex: SAP control parameters might be different in different environments. Hard coding this in either JAR files or code will make difficult to handle the changes.

10. Logs Levels: Logs can often degrade the performance of eGate system (integration server). It is very important to have the optimum logging levels to report errors & alerts. It is recommended to have debug level.


11. Error Reporting: While reporting errors, it is important to give enough information on the nature of the error (data/system, recoverable/non-recoverable exceptions). Basically the information in the error need to provide


The data/system error that is causing the error

Operation Performed (Date/String Manipulation)

Value of the data that is causing the problem

Tools like Common Service Framework automatically captures data like project name, service name, date/time stamps etc.


12. Exception Handling: Exceptions can be classified in to two types recoverable and non-recoverable. Recoverable exceptions can be processed once the data or system/connection issues are fixed or recovered (Ex: FTP server is unavailable to send data file). Non-recoverable exceptions cannot be processed and must be gracefully consumed. The exception details must be reported to CSF or some error database with the information that can be understandable to both business and technical teams (Ex: Parser/Unmarshal, JMS Exceptions etc).


13. Performance: Performance of the system can be improved by deploying services on a distributed network and make them communicate with each other. It is observed that multiple projects deployed on multiple integrations servers will provide a better system performance as the load is share across multiple integration servers. It is also recommended not to have more than 15 projects deployed on one domain. Having more than 15 projects leads to degradation of system performance and also more number of files are opened by IS which leads to exceptions that cannot be rectified using system configurations.



14. Fine Tuning Runtime Objects: It is important to fine tune certain runtime objects like Integration Server, JMS etc for optimal system performance. The integration server JVM parameters can be tailored to efficiently process the messages (Ex: Heap Size, Log Levels etc). Also JMS queues can be configured with maximum size of the messages. By default the heap size of integration server is set to 512 MB which is good enough to process messages. If more number of projects are deployed on the same integration server, it is suggested to have more heap size on the Integration server (-Xmx). This can be configured in asadmin. Ex: http://:/asadmin.

15. Parallel Testing Environments: It is Java CAPS feature that one project can be deployed on to one or more environments. It is possible to have multiple JCAPS testing environments on one server, provided they are uniquely identified by their domain base port numbers. Having parallel testing environments on one server will reduce the cost of EAI infrastructure and maintenance.


16. OTD Best practices

Data Base OTD
Stored Procedures/Prepared statements are preferred to perform database operations like select, insert, update and delete. Since they are pre-compiled, they will give optimum performance during runtime.


17. Collaboration Rule Best Practices:

Use Java coding standards to name the variables, constants, methods.

Use methods which return some object other than void

Use a StringBuffer object in place of a String object when doing concatenations

Close the open connections when you are done with the FTP operations.

While publishing the data into the JMS topic/queue, it is suggested to keep data size less than the DBS segment size to avoid JMS failures. It is observed that messages are consumed and lost with out giving a clue in the logs as the message size is larger than queue size. Often verify stcms.log file, when a message is lost.

Use Database batch updates/insertions/deletions. Also for each operation, an integer is returned that explains the number of records affected. The value must be captured as certain database operations provide no information when updation/deletion is not affected due to data issues.

Logger Object used for logging the information must be precisely used. Debug is used by default. But it is recommended to use fatal for logging exceptions.

Comments must be in detailed for each variable, constant, method used in the collaboration rules. This is very important practice on a maintenance perspective.

18. Connectivity Map Best Practices:

It is suggested to have one connectivity map per service layer (receiving, mapping and delivery). This will allow deploying each layer independently in a distributed network. Ex: Receiving Layer can be deployed in location A where it receives the data from external system that is residing in location A. Delivery layer can be deployed in location B where it sends data to external system that is residing in location B.



19. Processing Special Characters: JCAPS is incapable of processing certain special characters like Pound Sterling (£). It is automatically converted to Pound (#) before the data is sent to external system. Currently users are requested to enter GBP for pound symbol. We may either encypt/depcrypt or encode/decode the data to resolve this issue. This is a learning as well.



20. System Housekeeping and Cleanups:

1.Steps for eManager cleanup

Make sure the eManager is STOPPED.

Backup and delete the EventRepositoryDb.backup, EventRepositoryDb.data from emanager/EventRepositoryDb

Edit the EventRepositoryDb.script from the emanager/EventRepositoryDb folder and delete the following lines:

SET TABLE NOTIFICATION_EVENT INDEX 984 17
SET TABLE MSG_CODE_ARGS INDEX -1 0

Restart eManager after any of the above cleanup has been performed

2.Steps for Repository cleanup

Make sure the repository is STARTED.

Remove the locks for all the users by using the repository utility . This will remove any open locks and release the repository runtime resources.

Make sure the repository is STOPPED.

Remove the files under $repository/server/temp

3.Steps for domains cleanup



Make sure the domain is STOPPED.

Delete the folder $logicalhost/is/domains/

21. System Security: It is suggested to provide restricted access to users when multiple projects/users are working in groups. ACL can be applied against users to disable the access to rest of the projects which are not applicable to them. This also reduces the risk of accidental editing, deletions to the project objects.

Labels: , ,

 
Steps to create a new CAPS 6 domain
1. Create the new domain
    Ensure the .../appserver/bin folder is in your path (for asadmin) and create a new domain "domain2" with:
  
    asadmin create-domain --portbase 19000 domain2
 
   When prompted, use either the following defaults or your preferred values:
    Username = admin
    Password = adminadmin
    Master Password = changeit


2. Add STCMS to the new domain (optional)
    If you require STCMS (SeeBeyond JMS) support in the new domain, install embedded STCMS support into the new domain with:

    asadmin create-stcms --domainname domain2 --stcmsport 19007 IQ_Manager_19007

    Stcms instance created:
    Domain Path: C:\dev\CAPS6\appserver\domains\domain2
    Domain Name: domain2
    Stcms Name: IQ_Manager_19007
    Stcms Port: 19007
    Stcms SSL Port: 19008
    Stcms Enabled: true

3. Start the new domain
    Start the new domain with:

    asadmin start-domain domain2

    NB: You may see a NullPointerException when starting up the domain for the first time. This is due to Access Manager not being set up correctly on the new domain (a known issue). You can suppress the NPE by adding the following entry:

    am-configurator.enabled=false

   into the file
   domains//config/domain-registry before starting the domain for the first time. The first time you start the domain you will see the following message:

   Error: Access Manager - Can't find the node /domain/applications/lifecycle-module[@name= 'AMConfiguratorLifeCycleModule']/@enabled The operation DISABLE on the addon am-configurator is complete.

  Subsequent starts will now not display the error.

4. Install Runtime Installation

    Install the extra bits for CAPS 6, known as the Runtime Installation.

    You can do this either by configuring system properties or using a properties file. I choose to do this using the latter. For this, you need to locate and modify the install.properties file in your

   .../JavaCAPS6/appserver/addons/caps folder.

  Modify the following properties as necessary for your new domain. If you've used a different password, modify the relevant password fields also (the property names are self-explanatory).

    # The name of the domain caps.domain.name=domain2

    # The admin http or https port caps.admin.port=19048 If you require UDDI support (a WAR file to be deployed):

   # ----- UDDI ------------------------------------------
   # If the UDDI .war files need to be deployed, change this caps.uddi.install=true Likewise, if you require STCMS (SeeBeyond JMS) support set the following:

  # ----- STCMS ------------------------------------------
  # If STCMS needs to be installed, change this to true caps.stcms.install=true ...and uncomment the required operating system for installation, e.g. for Windows: caps.stcms.os=win32 Now, with domain2 running, execute the following to apply the CAPS 6 runtime using the new properties: asant -f ../addons/caps/install.xml NB: The above command assumes you are running it from the ../appserver/bin folder

Labels: , , , , , , ,

 
BatchInbound File Name Pattern - Working with JCAPS regular expression
Sometimes providing a pattern to any of the Batch Adapter in JCAPS can be a pain and involves a lot of Googling for an regex which actually would work for us. It may look simple intially but writing a wrong file regex pattern can cause dangling exception at runtime.

In case you are looking for file pattern which has to read any file with a particular extension like .cntl, you can use :
.*\.cntl


or may you need to read any file from a particular directory do use:
.*\.*$


The above file patterns have worked for JCAPS 5.1.X and JCAPS 6.

Incase you are looking for a specific pattern as per your requirement do write to me at manesh@jcapsmentor.com

Also, following are some sites which can help you to check the regex which you have thought about to implement in the Batch Adapter as patterns:

http://www.myregextester.com/
http://www.fileformat.info/tool/regex.htm

Regards,
Mak

Labels: , , , ,

 
JCAPS 6 Tour

OverView of JCAPS 6

Java CAPS 6 will include Netbeans 6.1, Glassfish v2 and OpenESB v2. It will also include the Repository module coming from Java CAPS 5 so that you will be able to import Java CAPS 5 projects. You can integrate Java CAPS 5 projects with OpenESB and Java EE applications because all are running on the same Glassfish v2 application server.

New Features of JCAPS 6

v NetBeans 6.1 Based Tooling

  • Complete backward compatible support for repository-based applications
  • JCA Adapter support in EJB Web Services
  • QoS (Quality of Service) enhancements in JBI Composite Application Editor
  • Support for Solaris, Linux and Mac

· Support for Repository, Java EE and JBI applications with Solid Management Foundation : Rich set of management APIs

· Scriptable with an JS-223 compliant scripting language

· Enterprise Manager enhanced for use with the Sun Java Application Server 9.1

· Integrated JBI (Java Business Integration) management in the Sun Java Application Server 9.1 console and CLI (Command Line Interface)

v Improved Installation Experience

· Simple installation with a set of preloaded components

· Multi-platform support: Windows, Solaris, AIX, Linux and Mac

· Service tag registration

v New JCA Adapter Pack that caters to the integrations needs of Java EE developers

· File, JMS, Batch, Oracle, Oracle Applications, JDBC, Siebel, TCP/IP, SAP BAPI and SAP ALE

· Available as a separate component in MEP (Message Exchange Pattern) Project

v Cluster enabled JBI runtime with Systemic Quality Improvements

v BPEL (Business Process Execution Language) 2.0 runtime is faster and scalable and includes a configurable QOS

v New Master Date Management (MDM) Suite

· Bulk matching and loading tool

· Service enabled

· Source extraction support by means of the Data Integrator

· New and enhanced Master Index Data Manager GUI

· Full XA Support

· Extensible matching and standardization engine

v Intelligent Event Processor (IEP): Offers the ability to identify trends and patterns in real-time, enabling organizations to address critical business issues and take corrective actions proactively.

v Business Process Management: Supports BPEL 2, includes new high availability and fail over features, and provides monitoring processes through integration with IEP.

v Open Source, Pluggable—Lowers risk and eliminates vendor lock-in through the development of Java CAPS in the Open ESB community.

v Unified—Provides a common design, management, and monitoring environment for all integration components within the suite.

v Comprehensive—delivers a complete, secure, scalable platform to support a service-oriented architecture (SOA) encompassing new development and legacy reuse.

v The complete JCAPS 6 Release installation includes

· NetBeans IDE

· Sun GlassFish Enterprise Server

· Sun Java MQ

· Sun JMS IQ Manager

· Java CAPS Enterprise Manager

· Java CAPS Repository

· Derby Java DB

· UDDI Server

· Core Products: ESB, BPM, Composite Page Designer, Data Integrator

· JBI Components: Java EE SE, BPEL SE, ETL SE, XSLT SE, SQL SE, HTTP BC, File BC, JMS BC,

· Encoders

· Repository-Based Adapters: Batch/FTP, DB2 Connect, eMail, File, HTTP(s), JDBC/ODBC, Oracle, SQL

Labels: , , , , , , , , ,

 
Manesh Abhimanyu
Manesh is a Sr. EAI Consultant, at present working in Singapore (Little Red Dot).

His focus is in the areas of SOA, ESB and Enterprise Architecture Management.

Contact him via email (mak2powerATyahoo.co.in)

Menu
Archives
Links
Website developed & maintained by

Manesh Abhimanyu K. (Mak)

Click here to contact Manesh









Free Domain CO.NR