For best performance, follow these recommendations when coding to the JMS or message service APIs:
Consider storage types carefully EAServer supports two options for message storage and delivery:
Persistent messages are stored in a remote database and also cached in memory. Since the messages are stored in a database, they are not lost when the server goes offline or restarts.
Transient messages are stored in memory only, and can be lost if the server goes offline or restarts.
EAServer processes transient messages faster because they do not require database interaction. However persistent messages offer more reliable delivery (depending on the settings described “Queue and topic settings”).
Use transient messages if your application requirements allow the possibility of lost messages. 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.
Use transactions only when necessary Transacted sessions create additional overhead. If some messages require transacted sessions but others do not, create a separate session for the nontransactional messages.
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 values, consider using compression.
Clean up after yourself Close resources such as connections, sessions, queues, and topics as soon as you no longer need them.
Copyright © 2005. Sybase Inc. All rights reserved. |