Section 7.5. Creating a Message


7.5. Creating a Message

Now we'll wrap the user's credit data in a CreditCheckRequestDTO object so we can send it as a JMS Message. Example 7-2 shows the code.

Example 7-2. CreditCheckRequestDTO.java
 package com.jbossatwork.dto; import java.io.*; public class CreditCheckRequestDTO implements Serializable {     private String name;     private String ssn;     private String email;     public CreditCheckRequestDTO(  ) {  }     public CreditCheckRequestDTO(String name, String ssn, String email)     {         this.name = name;         this.ssn = ssn;         this.email = email;     }     public String getName(  )     {         return name;     }     public void setName(String name)     {         this.name = name;     }     public String getSsn(  )     {         return ssn;     }     public void setSsn(String ssn)     {         this.ssn = ssn;     }     public String getEmail(  )     {         return email;     }     public void setEmail(String email)     {         this.email = email;     } } 

The CreditCheckRequestDTO is similar to the CarDTO that you saw in previous chaptersit has setters and getters for each data member. To send an object as a JMS Message, it must obey the following rules:

  • An object must implement java.io.Serializable.

  • Each data member must be serializable. By default, String, the Java primitives (int, float, and so on) and the Java primitive wrappers (Integer, Float, and so on) are all serializable.

The CreditCheckRequestDTO follows all the rules, so we're done. We've encapsulated the user's credit information, and now we'll send the CreditCheckRequestDTO as a JMS Message.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net