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 !=
    public void execute() {
    try {
    } catch(Throwable 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

    Listing 4 shows a sample usage of the framework.

    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.

    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.

    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)

    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.

    @ThingsExpo Stories
    BnkToTheFuture.com is the largest online investment platform for investing in FinTech, Bitcoin and Blockchain companies. We believe the future of finance looks very different from the past and we aim to invest and provide trading opportunities for qualifying investors that want to build a portfolio in the sector in compliance with international financial regulations.
    A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
    Imagine if you will, a retail floor so densely packed with sensors that they can pick up the movements of insects scurrying across a store aisle. Or a component of a piece of factory equipment so well-instrumented that its digital twin provides resolution down to the micrometer.
    In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settle...
    Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
    Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
    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...
    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...
    Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
    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...
    "IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
    When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
    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 ...
    We are given a desktop platform with Java 8 or Java 9 installed and seek to find a way to deploy high-performance Java applications that use Java 3D and/or Jogl without having to run an installer. We are subject to the constraint that the applications be signed and deployed so that they can be run in a trusted environment (i.e., outside of the sandbox). Further, we seek to do this in a way that does not depend on bundling a JRE with our applications, as this makes downloads and installations rat...
    Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
    DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
    In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
    Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
    "Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
    The IoT Will Grow: In what might be the most obvious prediction of the decade, the IoT will continue to expand next year, with more and more devices coming online every single day. What isn’t so obvious about this prediction: where that growth will occur. The retail, healthcare, and industrial/supply chain industries will likely see the greatest growth. Forrester Research has predicted the IoT will become “the backbone” of customer value as it continues to grow. It is no surprise that retail is ...