Sunday, March 8, 2009

What is the difference between BytesMessage and StreamMessage

Question :What is the difference between BytesMessage and StreamMessage?
Answer :BytesMessage stores the primitive data types by converting them to their byte representation. Thus the message is one contiguous stream of bytes. While the StreamMessage maintains a boundary between the different data types stored because it also stores the type information along with the value of the primitive being stored. BytesMessage allows data to be read using any type. Thus even if your payload contains a long value, you can invoke a method to read a short and it will return you something. It will not give you a semantically correct data but the call will succeed in reading the first two bytes of data. This is strictly prohibited in the StreamMessage. It maintains the type information of the data being stored and enforces strict conversion rules on the data being read.

What is the use of MapMessage

Question :What is the use of MapMessage?
Answer :A MapMessage carries name-value pair as it’s payload. Thus it’s payload is similar to the java.util.Properties object of Java. The values can be Java primitives or their wrappers.

What is the use of TextMessage

Question :What is the use of TextMessage?
Answer :TextMessage contains instance of java.lang.String as it’s payload. Thus it is very useful for exchanging textual data. It can also be used for exchanging complex character data such as an XML document.

What is the use of BytesMessage

Question :What is the use of BytesMessage?
Answer :BytesMessage contains an array of primitive bytes in it’s payload. Thus it can be used for transfer of data between two applications in their native format which may not be compatible with other Message types. It is also useful where JMS is used purely as a transport between two systems and the message payload is opaque to the JMS client. Whenever you store any primitive type, it is converted into it’s byte representation and then stored in the payload. There is no boundary line between the different data types stored. Thus you can even read a long as short. This would result in erroneous data and hence it is advisable that the payload be read in the same order and using the same type in which it was created by the sender.

What is the use of Message object

Question :What is the use of Message object?
Answer :Message is a light weight message having only header and properties and no payload. Thus if the received are to be notified abt an event, and no data needs to be exchanged then using Message can be very efficient

What is the basic difference between Publish Subscribe model and P2P model

Question :What is the basic difference between Publish Subscribe model and P2P model?
Answer :Publish Subscribe model is typically used in one-to-many situation. It is unreliable but very fast. P2P model is used in one-to-one situation. It is highly reliable

What is the role of JMS in enterprise solution development

Question :What is the role of JMS in enterprise solution development?
Answer :JMS is typically used in the following scenarios1. Enterprise Application Integration: - Where a legacy application is integrated with a new application via messaging.2. B2B or Business to Business: - Businesses can interact with each other via messaging because JMS allows organizations to cooperate without tightly coupling their business systems.3. Geographically dispersed units: - JMS can ensure safe exchange of data amongst the geographically dispersed units of an organization.4. One to many applications: - The applications that have to push data in packet to huge number of clients in a one-to-many fashion are good candidates for the use JMS. Typical such applications are Auction Sites, Stock Quote Services etc.
Your Ad Here