Progressing On Ording Group Impl
I created a OrderingGroupMonitor class. This class acts as a repository of ordering groups
and go with each MessagingQueue. It simply answers one question: Is a message deliverable
with respect to ordering group rule?
to enable this class to function properly, we need the following steps:
i) A messages is registered with the OrderingGroupMonitor whenever it is suitable for
handling ( as in ChannelSupport.handle() )
ii) When a message sending is finished, it will tell the OrderingGroupMonitor to release
it. ( as in acknowledge time, commit time, etc)
iii) When a message is peeked from the priority list for sending, it will first ask the
OrderingGroupMonitor if the message is deliverable wrt ordering. If not (as in wrong
order), we have to put the message back and let the queue to iterate to next message (when
putting back, we need to lower its priority in order to let other messages get chance to
deliver). If it is deliverable, the message will be sent the usually way.
iv) In tx case, ordering group can't be possible if the messages in a tx are acked in
batch mode. We have to make some changes, for example let some internal acknowledge
happen, to avoid such a dead lock.
public class OrderingGroupMonitor
{
HashMap<String, OrderingGroup> orderingGroups = new HashMap<String,
OrderingGroup>();
/**
* Check the message is it is a member of an ordering group, if so,
* put it in; if not, do nothing.
* if message is dropped due to maxSize being reached, it won't be
* get registered. (dont' know if the tx is needed or not yet, just put here for
now)
*/
public void registerMessage(MessageReference ref, Transaction tx)
{
String grpName = null;
try
{
grpName =
((JBossMessage)ref.getMessage()).getStringProperty(JBossMessage.JBOSS_MESSAGING_ORDERING_GROUP_ID);
}
catch (JMSException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if ( grpName == null )
{
return;
}
synchronized(orderingGroups)
{
OrderingGroup group = orderingGroups.get(grpName);
if (group == null)
{
group = new OrderingGroup();
}
group.add(ref);
}
}
/**
* If ref is not in our registry, just return true.
* If in our registry, check if the ref is the first of the group.
* return true if it at the first place. return false other wise.
*/
public boolean isDeliverable(MessageReference ref)
{
// TODO Auto-generated method stub
return false;
}
/**
* This method indicates a messgae is completed.
* it is called when a message is acked, commited or rollback
* once the message is completed, the next one in a ordering
* group becomes deliverable.
*/
public void messageCompleted(MessageReference message)
{
//remove reference from the repository
}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4181733#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...