| java.lang.Object org.netbeans.modules.wsdlextensions.jms.validator.RedeliveryHandlingParser
RedeliveryHandlingParser | public class RedeliveryHandlingParser (Code) | | Is used to deal with "poisonous messages". A poison message is a message that fails
to be processed time and time again, thereby stopping other messages from being
processed.
Is invoked for each message. Maintains a cache of msgids of messages that have the
JMSRedelivered flag set, and keeps a count of these messages. Based on the number
of times a message was redelivered, a particular Action can be invoked. Actions are
delay, moving or deleting the message.
The msgid cache is not persistent, nor is it shared between multiple activations. This
means that if a message was seen 10 times with the redelivered flag set, and the
project is undeployed, the redelivery count will be reset to zero. Also, if there are
multiple application servers reading from the same queue, a message may be redelivered
10 times to one application server, and 10 times to the other application server, and
both activations will see a count of 10 instead of 20.
The msgid cache is limited to 5000 (check source); when this limit is reached, the
oldest msgids are flushed from the cache. "Oldest" means least recently seen.
Specification of the actions is done through a specially formatted string. The string
has this format:
format := entry[; entry]*
entry := idx ":" action
idx := number (denotes the n-th time a msg was seen)
action := number (denotes delay in ms) | "delete" | "move"(args)
move := "queue"|"topic" | "same" ":" destname
destname := any string, may include "$" which will be replaced with the original
destination name.
Examples:
5:1000; 10:5000; 50:move(queue:mydlq)
This causes no delay up to the 5th delivery; a 1000 ms delay is invoked when the
message is seen the 5th, 6th, 7th, 8th, and 9th time. A 5 second delay is invoked
when the msg is invoked the 10th, 11th, ..., 49th time. When the msg is seen the 50th
time the msg is moved to a queue with the name "mydlq".
If the messages were received from "Queue1" and if the string was specified as
5:1000; 10:5000; 50:move(queue:dlq$oops)
the messages would be moved to the destination "dlqQueue1oops".
Another example:
5:1000; 10:5000
This causes no delay up to the 5th delivery; a 1000 ms delay is invoked when the
message is seen the 5th, 6th, 7th, 8th, and 9th time. A 5 second delay is invoked
for each time the message is seen thereafter.
Moving messages is done in the same transaction if the transaction is XA. Moving
messages is done using auto-commit if the delivery is non-XA.
Moving messages is done by creating a new message of the same type unless the
property JMSJCA.redeliveryRedirect is set to true in which case the messages are
simply redirected. In the first case, the payload of the new message is set as follows:
- for a ObjectMessage this will be done through getObject(), setObject();
- for a StreamMessage through readObject/writeObject,
- for a BytesMessage through readBytes() and writeBytes()
(avoiding the getBodyLength() method new in JMS 1.1)
Copying the payload of an ObjectMessage may cause classloader problems since the
context classloader is not properly set. In this case the redelivery handler should
be configured to redirect the message instead.
The new message will have properties as follows:
JMS properties
- JMSCorrelationID: copied
- JMSDestination: see above; set by JMS provider
- JMSExpiration: copied through the send method
- JMSMessageID: set by the JMS provider
- JMSPriority: set by the JMS provider; propagated through the send() method
- JMSRedelivered: NOT copied
- JMSReplyTo: copied
- JMSTimestamp: copied into the user property field JMSJCATimestamp
- JMSType: copied
- JMSDeliveryMode: set by the JMS provider; propagated through the send() method
All user defined properties: copied
Additional properties:
- JMS_Sun-JMSJCA.RedeliveryCount: number of times the message was seen with the redelivered
flag set by JMSJCA. Will accurately reflect the total number of redelivery attempts
only if there's one instance of the inbound adapter, and the inbound adapter was
not redeployed.
- JMS_Sun-JMSJCA.OriginalDestinationName: name of the destination as specified in the
activation spec
- JMS_Sun-JMSJCA.OriginalDestinationType: either "javax.jms.Queue" or "javax.jms.Topic"
- JMS_Sun-JMSJCA.SubscriberName: as specified in the activation spec
- JMS_Sun-JMSJCA.ContextName: as specified in the activation spec
Invoking a delay takes place by holding the processing thread occupied, that means
that while the thread is sleeping, this thread will not be used to process any other
messages. Undeployment interrupts threads that are delaying message delivery. If a
msg delay is divisible by 1000, an INFO message is written to the log indicating that
the thead is delaying message delivery.
There is a default behavior for message redelivery handling: see source.
Implementation notes: this class is made abstract to enhance testability.
|
Inner Class :abstract public static class Action | |
Inner Class :public static class VoidAction extends Action | |
Inner Class :public static class Delay extends Action | |
Inner Class :public static class Move extends Action | |
Inner Class :public static class Delete extends Action | |
Method Summary | |
public static boolean | checkValid(String actions) | public static Action[] | parse(String s, String destName, String destType) Parses an action string into separate actions and performs validations. |
checkValid | public static boolean checkValid(String actions)(Code) | | Parameters: actions - action string true if can be parsed properly |
parse | public static Action[] parse(String s, String destName, String destType) throws Exception(Code) | | Parses an action string into separate actions and performs validations.
The returned action array is guaranteed to be ordered and without duplicates.
Parameters: s - string to be parsed Parameters: destName - destination name being used (for dlq name construction) Parameters: destType - type from activation spec (javax.jms.Queue or javax.jms.Topic) array of actions throws: Exception - upon parsing failure |
|
|