{
final JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
try
{
// extract command from message
Command command = extractCommand(message);
if (log.isDebugEnabled())
{
log.debug("Extracted command " + command) ;
}
if (command == null)
{
discard(jbpmContext, message);
return;
}
final Object result = command.execute(jbpmContext);
// send a response back if a "reply to" destination is set
final Destination replyTo = message.getJMSReplyTo();
if (replyTo != null && (result instanceof Serializable || result == null))
{
sendResult(jbpmContext, (Serializable)result, replyTo, message.getJMSMessageID());