For best performance, follow these recommendations when designing and implementing JMS applications:
Consider storage types carefully EAServer supports two options for message storage and delivery, transient versus persistent:
Transient messages are stored in memory only. Applications based on transient messages run faster, however messages can be lost if the server goes offline or restarts.
Persistent messages are stored in a remote database and also cached in memory. The database interaction affects performance. However, since the messages are stored in a database, they are not lost when the server goes offline or restarts (reliable delivery depends on the settings described “Queue and topic settings”).
Use transient messages if your application requirements allow the possibility of lost messages. Use persistent messages if lost messages are never acceptable. For example, transient storage may suffice if the message is intended to notify retail customers of new catalog items. On the other hand, if the message represents a change to a customer’s account balance, use persistent storage for the most reliable delivery.
Transient messaging yields much better performance than persistent messaging for high-volume publish/subscribe applications such as stock or currency trading systems. Sybase recommends that you design these applications to work reliably with non-persistent messages. If messages might have been are lost, your application receives a JMSException error. If the applications takes appropriate action to cope with the possible loss of messages, you can use transient messaging.
Use message selectors If using the publish/subscribe model, message selectors save bandwidth by preventing the delivery of messages that the subscriber does not need. Do not scan and delete messages in your client code. Instead, create a selector so that the server filters messages before they cross the network.
Start consumers before producers Messages that you send before a consumer is available can create backlogs in the queue. If you can control the timing, make sure the consumer starts first.
Set the expiration time If appropriate, set the message time-to-live property. Doing so allows EAServer to free resources associated with the message when it expires. For example, in an automated trading application, you might set the time-to-live to 10 seconds for price-change messages, assuming this is the acceptable window for execution of trades that result from message receipt.
Set message priority If some messages must be delivered ahead of others, set the message priority property. Priority values are application assigned relative values ranging from 0 to 9. You must use them consistently in your application.
Minimize message size Longer messages consume more network bandwidth and take longer to process in memory. Design your message formats to eliminate unnecessary data.
For large message values, consider using compression Message compression can reduce network overhead and, for persistent messages, reduce database overhead.
In JMS clients, compress data sent over the network by setting the com.sybase.jms.dataCompression InitialContext property. Alternatively, use a JMS Provider instance and set the dataCompression property. For details, see Chapter 3, “Developing JMS Clients,” in the Java Message Service User’s Guide.
For persistent messaging, you can also configure the queue or topic properties to enable compression before persisting the message. See “Queue and topic data compression”.
Test system performance to determine whether enabling network and persistent message compression increases throughput. While compression can reduce database and network overhead, it increases CPU usage by EAServer and your client application.
Clean up unused JMS resources Close resources such as connections, sessions, queues, and topics as soon as you no longer need them.