03/01/2011
Overview of E-Commerce
E-Commerce, which stands for electronic commerce (also called electronic marketing) is a way of buying and selling goods using electronic systems such as the internet or other computer networks. Main types of E-Commerce *B2C Most large retail stores have an online website for purchasing goods. This type of e-commerce is called business to consumer(B2C). *B2B B2B is selling goods between companies. It is like manufacturer supplying goods to the retailer or wholesaler. Leading E-commerce Software's * ATG * IBM Websphere e-commerce * MarketLive
03/01/2011
03/01/2011
ATG Portal
03/01/2011
03/01/2011
03/01/2011
03/01/2011
DAF- 1.Nucleus
The DAF implements a component development model based on JavaBeans and JSPs. Developers assemble applications out of component beans (based on standard ATG classes or custom Java classes) by linking them together through configuration files in Nucleus, ATGs open object framework. Nucleus lets you assemble applications through simple configuration files that specify what components are used by the application, what parameters are used to initialize those components, and how those components hook up to each other. Any Java object with an empty constructor can act as a component in Nucleus Nucleus also takes on the task of creating and initializing components. Nucleus is the mechanism that gives those components a place to live, and a way for those components to find each other. Nucleus by itself provides no application-specific functions
Citrisys Solutions, Chennai 8
03/01/2011
03/01/2011
03/01/2011
10
/atg/dynamo/service/SMTPEmail
03/01/2011
11
GLOBAL. properties
GLOBAL.properties is a special properties file, not associated with any specific component that is often used to set logging levels for sets of components ATG7.x/DAS/config/GLOBAL.properties loggingError=true loggingWarning=true loggingInfo=true loggingDebug=false
Logging properties
Places logging messages into log # Uncomment the ScreenLog while in production mode files logListeners=\ atg/dynamo/service/logging/LogQueue,\ atg/dynamo/service/logging/ScreenLog Outputs logging messages to screen
03/01/2011 Citrisys Solutions, Chennai 12
03/01/2011
13
/artists/d/DaveMathews global
03/01/2011
15
/artists/d/DaveMathews global
Here, genre properties has been replaced with a new value rock and the other two properties ( website and email ) has been initialized with
http://www.dmb.com and dave@dmb.com resp.
03/01/2011
17
03/01/2011
18
03/01/2011
19
The DSP tag library supports both scripting and the JSP Expression Language. For example, the following two tags are equivalent: <dsp:valueof param="<%= currentCourse %>"/> <dsp:valueof param="${currentCourse}"/>
03/01/2011
20
03/01/2011
21
****567890123456
03/01/2011
22
03/01/2011
23
03/01/2011
25
For source code please see the attachment. For More information please refer atg documentation Progamming Guide Creating CustomTag Converters.
Adobe Acrobat Document
03/01/2011
26
03/01/2011
27
03/01/2011
03/01/2011
29
03/01/2011
30
03/01/2011
31
03/01/2011
32
Repository API
Explanation of the Previous RDF <item-descriptor name="user"> In the SQL repository, for example, an item descriptor might correspond to a Single database table, or encompass multiple tables. In short, the itemdescriptor maps with the sql tables. <table name="ctdc_user" type="auxiliary" id-column-name="user_id"> Here the type defines whether its one-one or one-many relationships. ATG supports auxiliary one-to-one relationship. multi one-to-many relationship. In our case, its auxiliary. So its a one-to-one relationship.
03/01/2011
33
Repository API
Explanation of the Previous RDF
<property name="maxNoOfLoginAttempt" data-type="int" category="Login Attempts" column-name="max_no_of_login_attempts" display-name="Number of Login Attempts"/> Here, each property maps to a column of a table. Each property is a RepositoryItem name -> property name. data-type -> represents data-type specifically to this property. If you want to define a property that refers to another item, use the item-type attribute to refer to that item (oneone relationship) category-> this will group the properties. ( you can see through the ACC). column-name-> represents the sql column-names. display-name-> represents the name to be displayed( you can see through the ACC) Please see the attachment to see the list of data-types ATG supports.
03/01/2011 Citrisys Solutions, Chennai
Adobe Acrobat Document
34
Repository API
<table name="ctdc_user_interests" type="multi" id-columnname="user_id" multi-column-name="sequence_num"> type=multi -> represents one-to-many relationships. multi-column-name=sequence_num -> ensures that the ordering of the multi-values are maintained. The column specified by the multi-columnname attribute is used for multi-valued properties of data type array, map, and list and is not used for sets (which are unordered). For map type properties, the values in the column specified by the multi-column-name attribute must be a string. For list or array type properties, these values should be an integer or numeric type, and must be sequential.
<property name="interests" data-type="list" category="User Interests" component-item-type="ctdcInterest" column-name="user_interest" displayname="interests" />
component-item-type -> is the name of the item descriptor that defines the item type of the members of the collection of repository items.
03/01/2011
35
Repository API
If the property is a collection of primitive data types such as string, int, and double, specify the data type of the members of the collection by with the component-data-type attribute in the <property> tag for the multi item property: <property name="interests" column-name="interest" data-type="array component-data-type="string"/> When you are operating on the returned value from a List, Set, or Map property, the code should be like List l = (List) item.getPropertyValue(" interests "); ArrayList al = new ArrayList(); al.addAll(l);
03/01/2011
36
03/01/2011
37
if (ifLoggingDebug())
logDebug("adding artist: " + artistItem.getPropertyValue("name"));
} catch (RepositoryException e) {
if (isLoggingError()) {
03/01/2011
38
Mutable Repositories
Repository and RepositoryItem provide a read-only view of repository elements MutableRepository is an extension that allows repository elements to be: Created Updated Deleted Manipulating a MutableRepositoryItem (a local copy of the data) only changes the repository when an explicit call to updateItem()or addItem()is made. Allow an item to be checked out of the repository, modified, and then resubmitted (so that the change will be reflected in the underlying data store) Provide a locking mechanism which prohibits any access of the data store while it is being modified
03/01/2011
39
03/01/2011
40
MutableRepositoryItem mutSongItem =
mutRepos.getItemForUpdate(pSongid,"song");
mutSongItem.setPropertyValue("artist",artistItem); mutRepos.updateItem(mutSongItem);
}
03/01/2011 Citrisys Solutions, Chennai 42
03/01/2011
44
Repository Queries
The most straightforward way of executing queries in a repository is using RQL using the RqlStatement class You can create an RQLStatement from a string using parseRQLStatement() RqlStatement statement = RqlStatement.parseRqlStatement( rql string); RQL statements are executed against a RepositoryView
03/01/2011
45
Repository repos = getRepository(); RqlStatement findArtistRQL; RepositoryView artistView = repos.getView("artist"); Object rqlparams[] = new Object[1]; rqlparams[0] = pArtistName; findArtistRQL = RqlStatement.parseRqlStatement("name = ?0"); RepositoryItem [] artistList =
findArtistRQL.executeQuery (artistView,rqlparams);
if (artistList != null) {
return artistList[0];
} return null;
} 03/01/2011
46
Example: a named <item-descriptor name="song"> query to return all jazz songs in the <named-query> repository <rql-query> <query-name>jazzSongs</query-name> <rql>genre = "jazz"</rql> </rql-query> </named-query> </item-descriptor>
public RepositoryItem[] getJazzSongs() { try { RepositoryView songView = getRepository().getView("song"); 1 if(songView instanceof NamedQueryView) { NamedQueryView nameView = 2 (NamedQueryView)songView; Query namedQuery = nameView.getNamedQuery("jazzSongs"); RepositoryItem[] results = nameView.executeQuery(namedQuery); } return results; }
<dsp:droplet name="/atg/dynamo/droplet/NamedQueryForEach"> <dsp:param name="repository" bean="/dynamusic/SongsRepository" /> <dsp:param name="queryName" value="jazzSongs" /> <dsp:param name="itemDescriptor" value="song" /> <dsp:oparam name="output"> <li> <dsp:a href="song.jsp"> <dsp:param name="itemId" param="element.id"/> <dsp:valueof param="element.title"/> </dsp:a> </dsp:oparam> </dsp:droplet>
Item-Descriptor Relationships
1. One-to-One Relationships: Lets see the Repository Definition file below; <item-descriptor name="user"> <table name="ctdc_user" type="auxiliary" id-column-name="user_id"> <property name="maxNoOfLoginAttempt" data-type="int" category="Login Attempts" column-name="max_no_of_login_attempts" display-name="Number of Login Attempts"/> </table> Explanation: We have to use the type=auxiliary for 1-1 relationship. Here, the property maxNoOfLoginAttempt of data-type int has been added to the item-descriptor user.
Item-Descriptor Relationships
dps_user
1-1 relationship
ctdc_user
03/01/2011
52
Item-Descriptor Relationships
One-Many Relationship: Lets see the repository Definition File below: <item-descriptor name="user">
<table name="ctdc_user_interests" type="multi" id-column-name="user_id" multicolumn-name="sequence_num"> <property name="interests" data-type="list" category="User Interests" componentitem-type="ctdcInterest" column-name="user_interest" display-name="interests" /> </table> </item-descriptor> <item-descriptor name="ctdcInterest"> <table name="ctdc_interest" type="primary" id-column-name="id"> <property name="id" display-name="id"/> <property name="name" data-type="string" column-name="name" displayname="Name"/> </table> </item-descriptor>
03/01/2011 Citrisys Solutions, Chennai 53
Item-Descriptor Relationships
Explanation: 1. For one-to-many the type should be multi. 2. multi-column-name="sequence_num is used to maintain an order. It is used with list data-type. 3. Atg supports Set, List, Map, or array data-types. 4. component-item-type="ctdcInterest - the name of the item descriptor that defines the item type of the members of the collection of repository items. We can use the String array for storing the multi-valued properties like component-data-type=String. 5. You cannot establish a default value for multi-valued attributes. 6. In Code, we can get the multi-valued properties like: List l = (List) item.getPropertyValue(" interests ");
03/01/2011 Citrisys Solutions, Chennai 54
Cascade Operations
The SQL repository uses the cascade attribute in a <property> tag to better handle hierarchical properties, which is to say properties with the item-type or component- tem-type attributes. The cascade attribute can have one or more of the values insert,update, or delete. For example: <property name="scenarios" itemtype="scenario" cascade="update,delete"/> The item is created, added, updated, and deleted along with the parent item. Cascade Insert: A new item of the type declared by the item-type attribute is also created. The cascade="insert" attribute is typically used with cascade="update" and cascade="delete" so management of this item is completely automatic. The cascade="insert" attribute is ignored for properties that use component-itemtype.
03/01/2011 Citrisys Solutions, Chennai 55
Cascade Operations
Cascade update: When you call updateItem, any modified referenced items are automatically updated. Any referenced items that are new (transient) items are added. Cascade delete: If a repository item has a property with the cascade="delete" attribute set, when you remove the repository item, any items that are referenced by the property are also removed. Also, when you remove a reference to this item, the item is automatically removed.
03/01/2011
56
03/01/2011
58
An object-oriented approach like that used by the SQL repository lets you define a base item descriptor class called clothing to hold the attributes common to coats and shorts. You can use simple inheritance to make coats and shorts subclasses of clothing. You can then model the data in your clothing catalog as follows:
03/01/2011
59
03/01/2011
60
03/01/2011
61
Derived Properties
This feature enables one repository item to derive property values from another repository item or from another property in the same repository item. For example, an organization might have divisions, departments, and employees, organized in a tree structure. A repository represents this tree structure with division, department, and employee item descriptors. Each of these item descriptors might define a property called spendingLimit. A business rule might specify that an employees spending limit comes from their department if it is not set for that employee. If the spending limit is not set for the department it should be derived from the spending limit for the division. This derived property relationship is represented in a repository definition file as follows:
03/01/2011
62
Derived Properties
<item-descriptor name="employee"> <property name="department" item-type="department"/> <property name="empSpendingLimit" data-type="int"/> <property name="spendingLimit" writable="false"> <derivation> <expression>empSpendingLimit</expression> <expression>department.spendingLimit</expression> </derivation> </property> </item-descriptor> <item-descriptor name="department"> <property name="division" item-type="division"/> <property name="deptSpendingLimit" data-type="int"/> <property name="spendingLimit" writable="false"> <derivation> <expression>deptSpendingLimit</expression> <expression>division.divSpendingLimit</expression> </derivation> </property> </item-descriptor> <item-descriptor name="division"> <property name="division" item-type="division"/> <property name="divSpendingLimit" data-type="int"/> </item-descriptor>
03/01/2011 Citrisys Solutions, Chennai 63
03/01/2011
64
03/01/2011
66
03/01/2011
67
03/01/2011
68
03/01/2011
69
03/01/2011
70
03/01/2011
71
03/01/2011
73
03/01/2011
74
<dsp:droplet name=" CTDCPriceRangeDroplet"> <dsp:oparam name="output"> <dsp:valueof param="minPrice/> <dsp:valueof param=maxPrice/> </dsp:droplet> Note:
The minPrice and maxPrice are the custom parameters which we created in the customDroplet. Please see the previous slide.
03/01/2011
76
FormHandlers
Atg Form handlers that can perform these tasks: Validate data before it is submitted. Detect missing information and display appropriate messages to the user. Direct users to different pages depending on form submission results. Read and write database or repository data. Form handlers are components that you typically build from one of the form handler classes provided by the ATG Adaptive Scenario Engine. All provided form handler classes are subclasses of atg.repository.servlet.GenericFormHandler, and inherit its properties and methods:
03/01/2011
77
FormHandlers
ATG Relationship Management Platform includes the following form handler classes: SimpleSQLFormHandler for working with form data that is stored in a SQL database. RepositoryFormHandler for saving repository data to a database. ProfileFormHandler class to connect forms with user profiles stored in a profile repository. SearchFormHandler for specifying properties available to a search engine. You can also extend these and other form handler classes to handle the specific needs of your application.
03/01/2011 Citrisys Solutions, Chennai 78
formExceptions
03/01/2011
03/01/2011
80
SimpleSQLFormHandler
Dynamo defines a class, atg.droplet.sql.SimpleSQLFormHandler, which implements a form handler for querying, inserting, updating, and deleting rows from a database table. This form handler requires that each row to be edited can be uniquely identified by a set of key columns. In other words, it cannot be used for queries, updates, or deletes that operate on more than one row at a time. The SimpleSQLFormHandler lets you interact with a SQL database directly, by specifying the table rows to query or update. This form handler relies only minimally on the repository layer, it requires you to know exactly which items are required.
03/01/2011
81
03/01/2011
82
03/01/2011
83
When a user submits this form, the preferredActivity property of the value property of the SkierHandler is set to the selected option, and is inserted in the appropriate row of the SKIER database table.
03/01/2011
84
03/01/2011
85
RepositoryFormHandler Properties
checkForRequiredProperties A boolean, specifies whether the form handler checks that all required properties are present during operation. clearValueOnSet A boolean, specifies whether the value dictionary for an item is cleared and reset from the database when its repositoryId property changes. itemDescriptorName A string that specifies the item descriptor items handled by this RepositoryFormHandler. repository Specifies the repository where items are added, updated, and deleted. requireIdOnCreate A boolean, specifies whether an item ID must be user-supplied when an item is created. If set to true (the default), an error is thrown if no ID is provided. If set to false and no ID is provided, an ID is generated for the item on the fly.
03/01/2011
86
RepositoryFormHandler Operations
Operation create Function Creates a repository item based on the value set in the form and adds it to the repository. If the repositoryId property is specified in the form, the new item is created with the given repository ID; otherwise, an auto-generated ID is used. Deletes from the repository the item specified by repositoryId. Updates the item described by repositoryId from the form values.
delete update
You associate one of these operations with a submit input tag. For example, the following input tag defines a submit button that creates a repository item: <dsp:input type="submit" bean="atg/dynamo/droplet/MyRepositoryFormHandler.create" value="Add CD"/>
03/01/2011
87
ProfileFormHandler
Connects forms with user profiles stored in a profile repository. You can use the ProfileFormHandler to set user profile properties without writing any Java or SQL code. The ProfileFormHandler handles the following tasks: Profile creation and updates User login and logout. Assignment of existing roles and organizations to individual users and groups of users.
For example, when a user logs into a site, a form can invoke the login operation as follows: <dsp:input bean="ProfileFormHandler.login" type="submit" value="Submit"/>
03/01/2011
88
03/01/2011
89
Customizing ProfileFormHandler
You can extend the ProfileFormHandler in the same way you are extending the other FormHandlers. public class MyProfileFormHandler extends ProfileFormHandler. { protected void preCreateUser // invokes before the handlecreate() public boolean handleCreate()// create user. protected void postCreateUser // Invokes after the handleCreate() }
03/01/2011
90
03/01/2011
When Called Before any setX methods are called After all setX methods are called Before any input tags that reference this component are rendered After page rendering is complete, before the socket is closed If an exception occurs when trying to call the setX method of a form
Citrisys Solutions, Chennai 92
03/01/2011
94
03/01/2011
03/01/2011
96
03/01/2011
97
03/01/2011
99
03/01/2011
100
03/01/2011
101
Transaction Management
A transaction is a set of actions that is treated as an atomic unit. Either all the actions take place , or none of them take place. When all the actions runs successfully the transaction commits, otherwise the transaction roll backs. For example transfer from one bank account to another. The transfer requires two separate actions. An amount is debited from one account, then credited to another account. Here either both the actions should take place or none. This means that both actions must take place within the same transaction. Each active transaction is represented by a transaction object, which implements the interface javax.transaction.Transaction. This object keeps track of its own status, indicating if it is active, if it has been committed or rolled back, and so on.
03/01/2011
102
Transaction Management
TransactionManager A transaction Manager provides services to support the management of transactional resources. The Transaction Manager is a services provided by the application server. The service implements a java interface javax.transaction.TransactionManager. The detailed operation of the Transaction Manager is normally hidden from the developer. The programmer need only worry about setting up transactional boundaries within the code. ATG uses TransactionManager as nucleus components. These components can be difficult to use. Fortunately ATG provides TransactionDemarcation class that allows you to demarcate program areas.
03/01/2011
103
Transaction Management
TransactionDemarcation This a a helper class that simplify the management of transaction boundaries. Transaction Demarcation is a term used to define the start and end points of a Transaction. This class contains two methods. 1.The begin() method is used to indicate the involvement of this process in the current transaction .Depending upon the arguments passed to this method,TransactionManager will decide whether to start a new transaction or have this process join in an existing transaction or produce an error. void begin(javax.transaction.TransactionManager pTransactionmanager,int pTransAtrribute)throws TransactionDemorcationExeception. 2. The end() method is used to indicate that the current process has completed its part of the transaction. Depending upon the mode, this may result in a commit or it may defer the commit to some other process. public int end() This method returns a status code indicating what happened to the transaction during the demarcated area.
03/01/2011 Citrisys Solutions, Chennai 104
Transaction Management
To use Transaction you need to understand the transaction demarcation modes: 1) Required: Indicates that a transaction must be in place in the demarcated area. If a transaction is already in place in the area, nothing further is done. If no transaction is in place, one is created when the demarcated area is entered and ended when the demarcated area ends. 2) RequiresNew: Indicates that all activity within the demarcated area must occur in its own separate transaction. If no transaction is in place in the area, a transaction is created at the beginning of the demarcated area and ended at the end of the demarcated area. If a transaction is in place when the demarcated area is entered, that transaction is suspended, and a new transaction is begun, at the end of the demarcated area, the new transaction is ended, and the original transaction is resumed. 3) NotSupported: Indicates that a transaction must not be in place in the demarcated area. If no transaction is in place in the area, nothing further is done. If there is a transaction in place when the demarcated area is entered, that transaction is suspended, then resumed at the end of the demarcated area.
03/01/2011 Citrisys Solutions, Chennai 105
Transaction Management
4) Supports: This mode does nothing. If a transaction is in place when the demarcated area is entered then that transaction remains in place. Otherwise, the area is executed without a transaction in place. 5) Mandatory: Throws an exception if a transaction is not in place when the demarcated area is entered. This mode does not create a transaction; it is used to verify that a transaction is in place where the developer expects 6 )Never: Throws an exception if there is a transaction in place when demarcated area is entered. This mode does not end or suspend any existing transactions; it is used to verify that a transaction is not in place where the developer does not expect one.
03/01/2011
106
Scheduler Services
Most server-side applications have routine tasks that must be performed periodically. For example, a component in the application might need to clear a cache every 10 minutes. Dynamo includes a Scheduler service, atg.service.scheduler.Scheduler, for doing this job. Writing a Schedulable Component. 1. Configure a Schedulable Component. scheduler=/atg/dynamo/service/Scheduler schedule=every 10 seconds. scheduler points to a Scheduler such as the standard Dynamo Scheduler. schedule points to the standard Dynamo Scheduler. The schedule property can be set in a wide variety of formats. Please refer the Atg Programming Guide for different time settings.
03/01/2011
107
Scheduler Services
Write a class which implements Scehdulable public class HelloJob extends GenericService implements Schedulable { // Scheduler property Scheduler scheduler; public Scheduler getScheduler () { return scheduler; } public void setScheduler (Scheduler scheduler) { this.scheduler = scheduler; } // Schedule property Schedule schedule; public Schedule getSchedule () { return schedule; } public void setSchedule (Schedule schedule) { this.schedule = schedule; } // Schedulable method public void performScheduledTask (Scheduler scheduler, ScheduledJob job) { System.out.println ("Hello"); }
03/01/2011
108
Scheduler Services
// Start method int jobId; public void doStartService () throws ServiceException { ScheduledJob job = new ScheduledJob ("hello", "Prints Hello", getAbsoluteName (), getSchedule (), this, ScheduledJob.SCHEDULER_THREAD); jobId = getScheduler ().addScheduledJob (job); } // Stop method public void doStopService () throws ServiceException { getScheduler ().removeScheduledJob (jobId); }
03/01/2011
109
03/01/2011
110
The Dynamo Application Framework includes a number of JMS-related tools, which are known collectively as the Dynamo Messaging System (DMS). The main parts of DMS are:
Two JMS providers, Local JMS and SQL JMS. Patch Bay - an API and configuration system layered on top of JMS.
03/01/2011
111
Local JMS is built for high-speed low latency synchronous messaging within a single process. SQL JMS is more robust, and uses a SQL database to handle communication between components within the same Dynamo application, or components running in different processes.
03/01/2011
112
Patch Bay is designed to ease the development of messaging applications in Dynamo. The Patch Bay API allows Nucleus components to send and receive messages. The configuration system uses an XML file to specify how these components should be connected. This file allows developers to change or add connections between components without changing code. Patch Bay also maintains a Message Registry that the Dynamo user interfaces use to present lists of possible notifications to users. Dynamo registers the messages that it sends with the Message Registry. Applications may also register their own messages, which will then appear in the Dynamo user interfaces.
03/01/2011 Citrisys Solutions, Chennai 113
The different pieces of the DMS can be use independently of each other. For example, we can use Local JMS, SQL JMS, or both, with or without Patch Bay. We can use a third-party JMS provider, or use the JMS implementation provided with our application server, also with or without Patch Bay.
03/01/2011
114
03/01/2011
115
Each JMSType corresponds to exactly one Message Bean class. For example, a message of JMSType atg.das.Startup will always be an ObjectMessage containing a bean of type atg.nucleus.dms.DASMessage. Multiple JMSTypes may correspond to the same Message Bean class. For example, JMSType atg.das.Shutdown also corresponds to atg.nucleus.dms.DASMessage. Messages avoid the use of application-specific header values. All such values are instead represented as properties of the contained message bean.
03/01/2011 Citrisys Solutions, Chennai 116
Local JMS does no queuing. When a message is sent, Local JMS immediately finds out who the receivers are and calls the appropriate methods on the receivers to deliver the message, waiting for each receiver to process the message before delivering the message to the next receiver. Only when the message has been delivered to all receivers does control return to the sender. In this way, Local JMS works more like Java Bean events than like typical JMS implementations; when a Java Bean fires an event, it actually calls a method on several registered listeners. Local JMS is also non-durable; all messages are nonpersistent. If a message is sent to a queue destination that has no listeners, the message disappears. Also, durable subscriptions to topic destinations act exactly like nondurable subscriptions if a subscriber is not listening to a topic, it will miss any messages sent to that topic whether it is subscribed durably or not.
03/01/2011 Citrisys Solutions, Chennai 118
Local JMS is most often used to pass data around to various components within a single request. For example, a user might view content on a certain page, thereby causing a message to be sent. A listener might be configured to listen for that message and update a value in the users profile as a result. The profile must be updated in the same request, or the updated value might not take effect in time for the next request. To make sure the sender and receiver both carry out their actions in the same request, the message should be carried over Local JMS. The same effect could be achieved by using a single component to watch for the user to view content then update the database. But by decoupling the two actions into separate components joined by JMS, the system allows new senders or receivers to be added to the system without changing any existing code.
03/01/2011 Citrisys Solutions, Chennai 119
We can use the DMS configuration file to create Local JMS destinations. These destinations are specified by name, separated into topics and queues:
<dynamo-message-system> <patchbay> ... </patchbay> <local-jms> <topic-name>/MyApp/RegistrationEvents</topic-name> <topic-name>/MyApp/FinancialEvents</topic-name> ... <queue-name>/MyApp/Orders</queue-name> ... </local-jms> </dynamo-message-system>
03/01/2011 Citrisys Solutions, Chennai 120
When Dynamo starts, it create these destinations with the JNDI names localdms:/local/MyApp/RegistrationEvent s, localdms:/local/MyApp/FinancialEvents, and localdms:/local/MyApp/Orders. Remember that Local JMS keeps no state, so adding these topics and queues simply creates named locations for messages to be sent locally. Nothing is actually added to a back-end storage system.
03/01/2011 Citrisys Solutions, Chennai 121
Local JMS implements synchronous, extremely high-performance messaging. However, many messaging applications require messaging to be asynchronous. When a sender sends a message asynchronously, the message is handed off to the JMS provider, and the sender continues on with its work. Once the sender passes the message to the JMS provider, the sender does not need to be informed if or when the message has been delivered to its final recipients. Asynchronous messaging is useful for processes that can be broken down into separate stages, where each stage might take an unknown amount of time.
03/01/2011 Citrisys Solutions, Chennai 122
For example, ATG Commerce uses asynchronous messaging to process an order. Each stage in the order (calculating tax, checking inventory, sending orders to shipping houses, sending confirmation e-mail to the user) is a single action that is activated by an incoming message from the previous stage, and ends by sending a message to the next stage in the process. When the user submits an order, a message is sent to the first stage in the process. The user is told that the ordering process has started, but will not know about the completion of the process until a later e-mail is sent. Another key difference between Local JMS and SQL JMS is message persistence. Local JMS stores no state, so if the system fails, all messages are lost. SQL JMS uses an SQL database for persistence of messages.
03/01/2011 Citrisys Solutions, Chennai 123
This insures that messages will not get lost in the event of a system failure, and enables support for persistent queues and durable subscriptions. To deliver messages, SQL JMS polls the database periodically, checking the appropriate tables to see if any new messages have been written. If so, those messages are delivered to the appropriate message receivers and then removed from the database. This all occurs transactionally, so if a failure occurs or the transaction rolls back, the messages are all returned to the database, again guaranteeing that messages do not get lost. In SQL JMS, the sending of a message and the receiving of a message occur in separate transactions. A sender might send a message in a transaction that later commits successfully.
03/01/2011 Citrisys Solutions, Chennai 124
This doesnt mean that the receiver has successfully received the message. It just means that SQL JMS has successfully delivered the message to its destination. At some point in the future, the receiving of the message will place in another transaction. The message will then be removed from the database when that second transaction successfully commits. SQL JMS uses standard JDBC drivers to communicate with the database. This allows SQL JMS to operate in a distributed environment, where Dynamo and the database are located on different machines. SQL JMS can also run on multiple Dynamos at once, all utilizing the same database. By default, the connection factory for all SQL JMS topic and queue connections (including XA connections) is the Nucleus component /atg/dynamo/messaging/SqlJmsProvider.
03/01/2011
125
From the developers perspective, very little changes when using SQL JMS instead of Local JMS. The message source and receiver components are still coded in essentially the same way whether they are using Local JMS or SQL JMS. The main difference is that the components are configured by pointing them at SQL JMS destinations rather than Local JMS destinations. In SQL JMS, destinations are represented by entries in the dms_queue and dms_topic tables, so adding new destinations is a matter of inserting new rows into these tables. However, this should not be done directly, as is difficult to coordinate this with the mechanism that generates new IDs for the destinations. Dynamo includes a browser-based application called as SQLJMSAdmin to administer and remove queues and topics.
03/01/2011 Citrisys Solutions, Chennai 126
Patch Bay
03/01/2011
127
Patch Bay is designed to simplify the process of creating JMS applications. Patch Bay includes a simplified API for creating Nucleus components that send and receive messages, and a configuration file where we declare these components and your JMS destinations. When Dynamo starts up, it examines this file and automatically creates the destinations and initializes the messaging components. This means our code does not need to handle most of the JMS initialization tasks, such as obtaining a ConnectionFactory, obtaining a JMS Connection, creating a JMS Session, etc.
03/01/2011 Citrisys Solutions, Chennai 128
The Patch Bay is represented in Nucleus as the component /atg/dynamo/messaging/MessagingManager, which is of class atg.dms.patchbay.PatchBayManager. In addition to the properties file, the MessagingManager uses an XML file called the DMS configuration file to configure the individual parts of the Patch Pay system, such as JMS providers, message sources and sinks, and destinations. The definitionFile property of the MessagingManager component names the DMS configuration file whose value is /atg/dynamo/messaging/dynamoMessagingSyst em.xml
03/01/2011 Citrisys Solutions, Chennai 129
Messaging Components As with standard JMS, the Patch Bay API includes Java interfaces that messaging components must implement in order to send and receive messages. However, these interfaces differ from the standard JMS interfaces, and the terminology is somewhat different: A component that can send messages is called a message source. A message source must implement the atg.dms.patchbay.MessageSource interface. A component that can receive messages is called a message sink. A message sink must implement the atg.dms.patchbay.MessageSink interface. A component that implements both interfaces (and can thus both send and receive messages) is called a message filter. All message sources, sinks, and filters must have global scope.
03/01/2011
130
Unlike standard JMS, Patch Bay does not have separate interfaces for objects that communicate with topics and those that communicate with queues. A message source can send messages to both topics and queues, and a message sink can receive messages from topics and queues. In addition to our sources and sinks, we must also define standard JMS destinations; Patch Bay cannot connect a message source directly to a message sink. Instead, the two must be connected through a JMS 03/01/2011 Citrisys Solutions, Chennai 131 destination.
Message sources follow a slightly more complicated protocol. After a message source is resolved in Nucleus, the Patch Bay calls MessageSource.setMessageSourceContext() on the component. This provides the component with a context object that it can use to create and send messages. However, the component should not begin to send messages yet. At this point, the Patch Bay initializes the various JMS providers and makes sure that the messaging infrastructure is up and running. It then walks through each of the message sources and calls MessageSource.startMessageSource() on each one.
03/01/2011 Citrisys Solutions, Chennai 133
After this call, the message sources can start sending messages. Depending on the message source, this method is where a message source will register itself with the scheduler, or start a server to listen for incoming messages, or just set a flag that gates the sending of messages. Message filters are combinations of message sources and message sinks. They implement both interfaces, and must follow the protocols for both.
03/01/2011 Citrisys Solutions, Chennai 134
Whenever a destination is specified in the DMS configuration file, it must specify which provider owns that destination. The destination must also be named by its JNDI name, using the prefix appropriate to that destinations provider.
03/01/2011
136
<message-source> <nucleus-name> /com/vam/MyMessageSource </nucleus-name> <output-port><port-name>DEFAULT</port-name> <output-destination> <provider-name>local</provider-name> <destination-name>localdms:/local/MyMessages </destination-name> <destination-type>Topic</destination-type> </output-destination></output-port></message-source>
The output-port definition is described in the Using Messaging Ports section of this chapter. The important part of this example is the outputdestination definition. This definition says that messages coming out of this Nucleus component should be directed to the topic called /local/MyMessages managed by a local provider.
03/01/2011 Citrisys Solutions, Chennai 137
If you only have one port it must be called DEFAULT. One Port can map on to multiple destinations also The port name must be passed into the sendMessage() call otherwise the message will go to the DEFAULT port Input and output port names in atg\dynamo\messaging\dynamoMessagingSystem. xml can be different. It's the affinity to the destination object which creates the relationship. The input port names are only visible to the MessageSink object and the output port names are only used by the MessageSource object
03/01/2011 Citrisys Solutions, Chennai 138
Message Ports
In the Patch Bay configuration, a component can be configured to send its messages to a destination (or group of destinations), or to receive its messages from a destination (or group of destinations). Sometimes, however, we may want a component to have more control over where its messages are going. For example, a message filter might read in a message and then resend that message to one of several outputs based on some aspect of the message, such as its JMSType. Each of those outputs would then be configured in the Patch Bay to go to a separate set of destinations. In the Patch Bay, those outputs are called ports.
03/01/2011 Citrisys Solutions, Chennai 139
The author of a messaging component chooses the names of the ports that will be used by that component. Whenever a message source (or filter) sends a message, it must specify the name of the port through which the message will be sent. This means that the port names used by the component will be hard-coded into the component. In the Patch Bay, each of a components output ports can be attached to a different set of destinations.
03/01/2011
140