Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Parallel Business Logic Processing

Parallel Business Logic Processing

When independent business components must be executed simultaneously, the parallel processing of application business logic has a direct impact on the performance of the system; however, parallel processing at the application level historically has been challenging to implement.

In the case of J2EE applications that rely on the services provided by the application server containers, implementing parallel and concurrent processing is an uphill battle. Over time, the Java messaging services (JMS) API has become a de facto solution for parallel business logic processing by utilizing the asynchronous messaging features offered by the API.

Although JMS provides a solid foundation for developing J2EE applications that use asynchronous messaging, it does not automatically produce the desired end result. JMS poses the following challenges:

  • JMS provides the pieces to solve the puzzle, but it does not put the pieces together to achieve an accurate solution.
  • Even a JMS expert would have to overcome pitfalls and booby traps on the road to a successful implementation.
  • Best practices disapprove of the scattering of complex JMS code throughout an application. Because of these challenges, a reusable, flexible, and robust framework must be built to enable J2EE applications to exploit the asynchronous JMS features in order to achieve efficient parallel business logic processing. One such framework can be implemented by using JMS 1.0.2 and support for EJB 2.0 message-driven beans in the BEA WebLogic 6.1 Application Server.

    A real-world example of this design strategy resulted in a reusable framework that can be used in any J2EE application development scenario that requires an asynchronous mode of execution. This particular instance employed a black-box strategy by utilizing traditional proxy and command patterns.

    Typical Approach
    When possible solutions to parallel business logic processing are considered, the first approach that comes to mind is spawning of threads. Multiple threads can be created to run each business task. This may work fine for simple applications; however, for enterprise applications that involve critical customer transactions and the exchange of huge chunks of data between multiple diverse systems, thread spawning may not be a robust solution. This type of design can lead to an interminable pursuit of perfecting the implementation itself because of the challenges involved in the management of thread life cycle, maintenance of the thread pool, management of transaction atomicity, and elimination of concurrency issues. An ounce of prevention is worth a pound of cure, so eschew this approach in the first place and follow a robust design from the outset.

    Design Summary
    Multiple different strategies were considered for implementing such a framework. Certainly there could be myriad implementation approaches, but the best approach is the one that takes advantage of the underlying application server. One such approach was based on leveraging BEA WebLogic Server's high-performance JMS implementation.

    The design strategy was based on sending messages containing action commands asynchronously to a JMS queue. Based on the implementation, an action command can perform any business task on execution. The main components in the design are:

    • Action command
    • Action message
    • Facade bean
    • JMS handler as a message producer
    • Message-driven bean as a message consumer
    • Message queue
    • Temporary queue
    The bean diagram visually depicts the participating components, the flow of request messages from the client of the framework to the message-driven bean, and the flow of response messages from the message-driven bean back to the client (see Figure 1).

     
    Figure 1: J2EE environment

    Implementation Details
    Action Command

    The action command represents the actual business logic to be executed. A standard interface was created for the action command so that different implementations of the command can be plugged in based on different requirements. The command interface defines two important methods, shown in the following code snippet:

    public interface Action extends Serializable{
    public void execute() throws Throwable;
    public Object getResult();
    }

    The action command is designed as a selfcontained entity and is expected to contain the results of business logic execution. The getResult method returns the resultant object. This approach guarantees that the business logic and the results of business logic execution are completely isolated from the framework. The framework itself acts like a black box and only provides the means to execute the business logic, leaving intricate business logic details to the actual implementation of the action command.

    Action Message
    The action message acts as an adapter to the action command. The purpose of the action message is to shield the message-driven bean from dealing with the error conditions and the status of action command execution. Action message also helps the JMS handler correlate the messages sent to the message queue and the messages received from the temporary queue. The framework client can check for the status of the action command execution by inspecting the corresponding action message. The following code shows the important methods in the ActionMessage class:

    public class ActionMessage implements
    Serializable {
    ...............................
    public boolean hasThrowable() {
    return (throwable !=
    null);
    }
    public void execute() {
    try {
    theAction.exe
    cute();
    } catch(Throwable t) {
    setThrowable(t);
    }
    }
    }

    Facade Bean
    A facade was incorporated into the framework to prevent the client from knowing the intricate details of the JMS implementation. This facade is implemented as a stateless session bean. The facade bean is an entry point into the framework - the client of the framework creates a list of action commands and sends the list to the facade bean by invoking the sendAll method. The facade bean internally delegates the handling of action commands to a JMS message handler. It is responsible for looking up the JNDI context for the JMS message queue and connection factory and uses this information to create its own JMS message handler.

    The timeout value on the sendAll method is used by the JMS message handler to set the timeout on the messages to be received from the temporary queue.

    There are three main advantages to using the facade bean. First, it shields the clients from the intricacies of the JMS implementation. Second, the method invocation on the facade bean can take part in transaction management. Finally, because the EJB container pools the facade bean instances, the JMS resources such as temporary queues, queue sessions, and queue connections used internally by each bean instance will automatically get the pool effect, ensuring economical utilization of the resources. The facade session bean supports both remote and local invocations by defining remote and local interfaces (see Listing 1).

    JMS Message Handler
    The JMS message handler is the actual component that encapsulates the nitty-gritty details of JMS implementation. The AsyncMessenger class represents a JMS handler. The facade bean delegates the list of action commands to the AsyncMessenger instance by invoking the sendAll method. The AsyncMessenger instance first wraps each action command in an action message object. It then creates a JMS message instance of javax.jms.ObjectMessage type. The AsyncMessenger sets the action message object as a serializable payload in the JMS ObjectMessage instance. It also creates a temporary queue and registers a JMS queue receiver for receiving the response messages from the temporary queue. It includes a reference to the temporary queue in the JMS message. Finally, it sends the JMS message to the message queue asynchronously.

    Since the execution time for each action command can vary, the sequence in which the response messages are received by the AsyncMessenger may not exactly match the sequence in which the request messages were sent. In order to guarantee the exact mapping of the response message to the corresponding request message, a unique multiplexing ID is associated with each request message. This ID is nothing but the index of the original action command in the list. The AsyncMessenger sets this ID as an attribute in the request action message, retrieves it from the response action message, and uses it to set the action message in the response list at the same location as the original request message was in the input list.

    Message Driven Bean (MDB)
    An MDB is used as the message consumer to retrieve and process the messages transported via a message queue. The EJB container is responsible for managing the life cycle of MDBs. At runtime, the EJB container creates many MDB instances and keeps those instances in a pool. After creating an instance in the pool, the EJB container takes care of subscribing the instance to a specified message topic or connecting the instance to the specified message queue, based on the JMS information provided in the MDB deployment descriptor. The main advantage of using MDBs over custom JMS message consumers is that MDBs are inherently JMS message consumers and the EJB container provides a robust environment for MDBs. Because MDB instances in the pool can concurrently consume and process hundreds of messages, MDBs are capable of providing higher throughput and scalability than most traditional JMS message consumers.

    In the current implementation, on notification of a JMS message, an MDB retrieves the action message from the JMS Object message and invokes the execute method on the action message. This invocation will trigger the actual execution of the action command contained by the action message. After execution is completed, the MDB creates a new JMS Object message and sets the action message as a payload. It then retrieves the reference to the temporary queue from the input JMS message and sends the newly created JMS message to the temporary queue of the JMS handler. This point-to-point messaging assures guaranteed delivery of the response to the authentic original caller.

    Message Queue
    Point-to-point (P2P) messaging was chosen for the example implementation because it offers a guarantee of the message being processed once-and-only-once by one-and-only-one message consumer. In the example case, the business logic should be executed once and only once, but in tandem. The main component that makes P2P work is the message queue, which basically decouples the message producer from the message consumer. Several message consumers can connect to the same queue, but the underlying JMS server guarantees that the message in the queue is delivered to one and only one message consumer. In the example implementation, a message queue is configured as the primary destination for all the action messages (the MDB instances being the primary message consumers).

    Normally, a message in the queue is delivered to the consumer in the order it was placed in the queue. The BEA WebLogic 6.1 JMS implementation provides the flexibility of sorting the delivery order of the queue messages by configuring destination keys. It enables "LIFO" and "FIFO" ordering of message queues. To enable FIFO (first-in-first-out retrieval of the messages in the queue), the sorting order of the JMS messages is configured by setting an ascending destination key in the BEA WebLogic 6.1 server JMS configuration.

    Temporary Queue
    A temporary queue is typically used by JMS clients to participate in requestresponse messaging using the JMS point-to- point protocol. A temporary queue belongs uniquely to the creating JMS queue session, and its life spans the entire duration of the queue session's connection unless the temporary queue is deleted. Unless its reference is transferred to other JMS clients using the JMSReplyTo header, the temporary queue is only accessible by the JMS client that created it. Although multiple different JMS clients can send messages to a temporary queue, JMS messages from the temporary queue can only be consumed by the JMS queue session associated with the JMS connection that created the temporary queue.

    The BEA WebLogic 6.1 Server enables easy creation of temporary queues. A JMS template has to be configured on a BEA JMS server to enable the creation of temporary queues in that JMS server. A JMS template provides an efficient means of defining multiple destinations with similar attribute settings.

    In the current framework, the JMS handler creates a temporary queue in order to receive responses from the MDB that executes the action messages.

    Complete Picture
    Figures 2 and 3 depict the relationship and message flow between the component classes.

     
    Figure 2: Class diagram
     
    Figure 3: Class diagram

    Deployment Details
    Deployment Descriptors

    The first step in deployment is to create the deployment descriptors for the facade session bean and MDBs. The XML fragments shown in Listings 2 and 3 ( due to space limitations, Listing 3 and 4 are online at www.sys-con.com/weblogicsourcec.cfm). are a sample deployment description. The next step is to JAR up the EJBs and run the BEA WebLogic ejbc utility. The final JAR file is ready to be deployed using the BEA WebLogic Admin Console.

    BEA WebLogic 6.1 Setup
    1.  Configure the WebLogic JMS connection factory (see Figure 4).

     
    Figure 4: JMS connection factory

    a.   In the left pane of the Admin Console, click on Connection Factory node and then click on the "Configure a new JMS Connection Factory" link in the right pane.
    b.   On the General tab, give the connection factory a name and a JNDI name. Fill in other attributes as appropriate, and then click on Create.
    c.   Fill in the Transactions and Flow Control tabs, as appropriate. Click on the Apply button on each tab when changes are completed.
    d.   On the Targets tab, target a WebLogic server instance or a server cluster on which to deploy the connection factory by selecting either Servers tab or Clusters tab.

    2.  Configure the WebLogic JMS template.
    a.   In the left pane of the Admin Console, click on the Templates node and then click on the "Configure a new JMS Template" link in the right pane.
    b.   On the General tab, specify a name for the template and click on the Create button.
    c.   Fill in the Thresholds & Quotas, Override, and Redelivery tabs, as appropriate. Click on the Apply button on each tab when changes are completed.

    3.  Configure the WebLogic destination key.
    a.   In the left pane of the Admin Console, click on the Destination Keys node and then click on the "Create a new JMS Destination Key" link in the right pane.
    b.   On the Configuration tab, specify a name, sorting property, key type, and sorting order direction.
    c.   After specifying all the attributes, click on the Apply button.

    4.  Configure the WebLogic JMS Server.
    a.   In the left pane of the Admin Console, click on the Server node and then click on the "Configure a new JMS Server" link in the right pane.
    b.   On the General tab, specify the server name, a store if one has been created, a paging store if one has been created, and select the previously created template as a temporary template for the server.
    c.   Click on the Create button to create the server.
    d.   Fill in the Thresholds & Quotas tab as appropriate, and then click on the Apply button to finalize the changes.
    e.   On the Targets tab, target a WebLogic Server instance and apply the changes. 5. Configure the WebLogic queue (see Figure 5).

     
    Figure 5: AsyncJMSQueue

    a.   Under the Servers node in the left pane of the Admin Console, expand the newly created JMS server instance and click on the Destinations node.
    b.   Click on the "Configure a new JMSQueue" link in the right pane.
    c.   On the General tab, specify the queue name and the queue JNDI name.
    d.   Choose the previously created destination key from the available list of destination keys and move it to the chosen list.
    e.   Click on the Create button to create the queue.
    f.   Fill in the Thresholds & Quotas, Override, and Redelivery tabs as appropriate; click on the Apply button on each tab to finalize the changes.

    6.  Configure the facade session bean and MDBs.
    a.   Under the Deployments node on the left pane of Admin Console, click on the EJB node.
    b.   Click on the "Configure a new EJB link" on the right pane.
    c.   On the General tab in EJB component pane, specify the EJB name, path to the EJB jar file and deployment order.
    d.   Click on the Deployed checkbox to set the deployment status for the component.
    e.   Click on the Create button to create the component.
    f.   On the Targets tab, target a WebLogic Server instance or cluster instance and apply the changes

    Usage
    Listing 4 shows a sample usage of the framework.

    Benchmarking
    Performance benchmarking was conducted with and without the framework on an airline e-commerce application that displays passenger itinerary information. The application retrieves data by interacting with many heterogeneous data sources, ranging from relational databases to mainframe legacy systems. Distinct data access objects are used to access data from different data sources and an aggregator service component was put into place to interact with a diverse set of data access objects and to assemble the retrieved data.

    Without using the framework, the aggregator service would assemble data by invoking data access objects in a synchronous fashion. In this case, it was anticipated that the overall response time would be very high, and the application performance would be very poor. This expectation was proved accurate by conducting a load test on the application: if there are five itineraries on average per passenger, the average response time to retrieve complete information is about 35 seconds. The load test on the application proved that unless a parallel and concurrent data retrieval mechanism is implemented, the optimization of response times will be exceptionally difficult.

    The framework was incorporated into the application such that the aggregator service would simultaneously invoke data access objects asynchronously, and another round of load testing was conducted on the application. This test yielded positive results indicating an average response time of about seven seconds. Thus, application performance increased almost five fold by using the framework.

    Conclusion
    A reusable, extensible, and robust framework that utilizes the asynchronous features offered by JMS and the robust runtime environment provided by the EJB container can solve the problem of parallel and concurrent business logic processing in enterprise and mission-critical applications. The benchmarking of an airline application running in a BEA WebLogic 6.1 Application Server yielded very positive response times and higher performance when the framework was incorporated into the application for parallel and concurrent data access from multiple data sources. The implementation of the framework proved to be much more robust than the typical thread-based implementation.

    Acknowledgments
    We would like to thank Virgil Bistriceanu, managing director, and Helen Agulnik, manager, for their support and inspiration in writing this article. We would also like to extend our special thanks to our colleague Kelly Oliver, who contributed her time by reviewing and editing the article.

  • More Stories By Murali Kashaboina

    Murali Kashaboina leads Enterprise Architecture at United Airlines, Inc. He has 15+ years of enterprise software development experience utilizing a broad range of technologies, including JEE, CORBA, Tuxedo, and Web services. Murali previously published articles in WLDJ and SilverStream Developer Center. He has master’s degree in mechanical engineering from the University of Dayton, Ohio.

    More Stories By Bin Liu

    Bin Liu is a lead software engineer at United Airlines. Bin has more than seven years of experience developing distributed applications using J2EE technologies, WebLogic, Tuxedo, C++, and Web services. Bin has previously published articles in WLDJ.

    Comments (2) View Comments

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    Most Recent Comments
    Cameron Purdy 01/20/04 10:55:45 AM EST

    Another approach is called Agent programming. Combined with Grid Computing, you can achieve massive parallel computing capabilities with Java. Our Coherence product supports this via the Invocation Service.

    John Pujol 11/10/03 11:49:01 PM EST

    This idea is very good. I was always wondering how to use asynchronous messaging within my application running in J2EE environment. This framework gives me a direction to follow in my future projects where I might have to use asynchronous method calls.

    Excellent piece of idea.

    @ThingsExpo Stories
    In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
    With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
    The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
    Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
    No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
    Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
    In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
    Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...
    @DevOpsSummit at Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, is co-located with 22nd Cloud Expo | 1st DXWorld Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait...
    Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
    SYS-CON Events announced today that T-Mobile exhibited at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on qua...
    SYS-CON Events announced today that Cedexis will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Cedexis is the leader in data-driven enterprise global traffic management. Whether optimizing traffic through datacenters, clouds, CDNs, or any combination, Cedexis solutions drive quality and cost-effectiveness. For more information, please visit https://www.cedexis.com.
    SYS-CON Events announced today that Google Cloud has been named “Keynote Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Companies come to Google Cloud to transform their businesses. Google Cloud’s comprehensive portfolio – from infrastructure to apps to devices – helps enterprises innovate faster, scale smarter, stay secure, and do more with data than ever before.
    SYS-CON Events announced today that Vivint to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. As a leading smart home technology provider, Vivint offers home security, energy management, home automation, local cloud storage, and high-speed Internet solutions to more than one million customers throughout the United States and Canada. The end result is a smart home solution that sav...
    SYS-CON Events announced today that Opsani will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Opsani is the leading provider of deployment automation systems for running and scaling traditional enterprise applications on container infrastructure.
    SYS-CON Events announced today that Nirmata will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nirmata provides a comprehensive platform, for deploying, operating, and optimizing containerized applications across clouds, powered by Kubernetes. Nirmata empowers enterprise DevOps teams by fully automating the complex operations and management of application containers and its underlying ...
    SYS-CON Events announced today that Opsani to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. Opsani is creating the next generation of automated continuous deployment tools designed specifically for containers. How is continuous deployment different from continuous integration and continuous delivery? CI/CD tools provide build and test. Continuous Deployment is the means by which...