{
Object result = null;
incrementMessageCount(false, message);
MessageDestination dest = (MessageDestination) getDestination(message);
// Throttle the inbound message - this also attempts to prevent duplicate
// messages sent by a client.
ThrottleResult throttleResult;
if (throttle)
throttleResult = dest.getThrottleManager().throttleIncomingMessage(message);
else
throttleResult = new ThrottleResult(ThrottleResult.RESULT_OK);
int throttleResultCode = throttleResult.getResultCode();
MessageException me = throttleResult.getException();
if (throttleResultCode == ThrottleResult.RESULT_ERROR)
{
throw me;
}
else if (throttleResultCode == ThrottleResult.RESULT_IGNORE)
{
if (Log.isDebug())
Log.getLogger(LOG_CATEGORY).debug(me.getMessage(), me);
}
else
{
// Block any sent messages that have a subtopic header containing
// wildcards - wildcards are only supported in subscribe/unsubscribe
// commands (see serviceCommand() and manageSubscriptions()).
Object subtopicObj = message.getHeader(AsyncMessage.SUBTOPIC_HEADER_NAME);
if (subtopicObj instanceof Object[])
subtopicObj = Arrays.asList((Object[])subtopicObj);
if (subtopicObj instanceof String)
{
String subtopicString = (String) subtopicObj;
testProducerSubtopic(dest, subtopicString);
}
else if (subtopicObj instanceof List)
{
List subtopicList = (List) subtopicObj;
for (int i = 0; i < subtopicList.size(); i++)
testProducerSubtopic(dest, (String) subtopicList.get(i));
}
// override TTL if there was one specifically configured for this destination
ServerSettings destServerSettings = dest.getServerSettings();
if (destServerSettings.getMessageTTL() >= 0)
message.setTimeToLive(destServerSettings.getMessageTTL());
long start = 0;
if (Log.isDebug())
start = System.currentTimeMillis();
// Give MessagingAdapter a chance to block the send.
ServiceAdapter adapter = dest.getAdapter();
if (adapter instanceof MessagingAdapter)
((MessagingAdapter)adapter).getSecurityConstraintManager().assertSendAuthorization();
MessagePerformanceUtils.markServerPreAdapterTime(message);
result = adapter.invoke(message);