Methods Summary |
---|
public void | doWork()Actual work happens in this method. DeliveryChannel available
from the super class. If there is any MessageReceiver waiting
for this message, then the MessageExchange is made avalable to that
MessageReceiver. If no MessageReceiver is interested in this MEP,
then a new MessageProcessor will process this message.
In the latter case, the message is for a 109 webservice deployed
in appserver.
while (true) {
try {
MessageExchange me = getDeliveryChannel().accept();
if (released) {
break;
}
if(me != null) {
if(ignoreMessageExchange(me)) {
continue;
}
String id = me.getExchangeId();
// The full block is not synchronized since,
// 1. Id will always be unique
// 2. Service engine will register the receiver
// before sending and hence we wont miss any.
if (receivers.containsKey(id)) {
synchronized(receivers) {
MessageReceiver receiver = receivers.remove(id);
receiver.setMessageExchange(me);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,
"Releasing MessageReceiver:" + id + ",MEP :" + me);
}
receiver.release();
}
} else {
MessageProcessor processor =
JavaEEServiceEngineContext.getInstance().
getBridge().getMessageProcessor(me);
processor.setUseCurrentThread(false);
processor.setMessageExchange(me);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,
"Spawning MessageProcessorfor MEP :" + me);
}
processor.process();
}
}
} catch (MessagingException ie) {
//Someone has interrupted the acceptor. Gracefully comeout.
logger.log(Level.FINE, "Stopping the acceptor thread");
break;
}
}
|
private boolean | ignoreMessageExchange(javax.jbi.messaging.MessageExchange me)
if(me.getRole().equals(MessageExchange.Role.PROVIDER)) {
if(me.getStatus().equals(ExchangeStatus.ACTIVE)) {
return false;
}
if(me.getStatus().equals(ExchangeStatus.DONE)) {
if(logger.isLoggable(Level.FINE)) {
logger.fine("Message Exchange Completed " + me);
}
return true;
}
if(me.getStatus().equals(ExchangeStatus.ERROR)) {
logger.warning("JavaEE Service Engine received unsupported Message Exchange " + me);
return true;
}
}
return false;
|
public void | register(MessageReceiver receiver)Add a MessageReceiver object that waits for a reply from
from NMR on their 2-way message exchange.
String id = receiver.getMessageExchange().getExchangeId();
logger.log(Level.FINER, "Adding recever for " + id);
synchronized (receivers) {
receivers.put(id, receiver);
}
|
public void | release()Release the thread from accepting. This method doesnt interrupt
the thread. It is just a soft release applicable only from the
next iteration of acceptor thread.
released = true;
|
public void | startAccepting()Start the acceptor thread. Note that execute() inturn call
doWork method, where bulk of logic is present.
execute();
|