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.
 package com.jbossatwork.dto; import*; public class CreditCheckRequestDTO implements Serializable {     private String name;     private String ssn;     private String email;     public CreditCheckRequestDTO(  ) {  }     public CreditCheckRequestDTO(String name, String ssn, String email)     { = name;         this.ssn = ssn; = email;     }     public String getName(  )     {         return name;     }     public void setName(String 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)     { = 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

  • 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

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: