qos.setKeyOid(this.uniqueKey);
qos.setState(Constants.STATE_OK);
qos.setRcvTimestamp(publishQosServer.getRcvTimestamp());
publishReturnQos = new PublishReturnQos(serverScope, qos);
MsgKeyData msgKeyData = (MsgKeyData)msgUnit.getKeyData();
msgQosData = (MsgQosData)msgUnit.getQosData();
/* Happens in RequestBroker already
if (msgQosData.getSender() == null) {
msgQosData.setSender(publisherSessionInfo.getSessionName());
}
*/
// Do a log.warning if topic meta XML is different
if (!clientTagLog) {
try {
XmlKey xmlKey = this.xmlKey;
if (xmlKey != null) {
String newTags = msgKeyData.getClientTags();
if (newTags != null && newTags.length() > 0) {
String oldTags = ((MsgKeyData)xmlKey.getKeyData()).getClientTags();
if (!newTags.equals(oldTags)) {
log.warning(ME+": Changing topic meta information from '" + oldTags + "' to '" + newTags + "' is not supported and this change is ignored, please check your publisher.");
clientTagLog = true;
}
}
}
}
catch (Throwable e) {
e.printStackTrace();
log.severe(ME+": Ignoring unexpected exception during meta info check:" + e.toString());
}
}
if (msgQosData.isAdministrative()) {
if ( isUnconfigured() || isSoftErased() || allowedToReconfigureTopicAndFixWrongLimits(msgQosData)) {
administrativeInitialize(msgKeyData, msgQosData, publishQosServer);
if (!msgQosData.isFromPersistenceStore()) {
msgQosData.setAdministrative(true);
msgQosData.setRcvTimestamp(this.topicEntry.getMsgQosData().getRcvTimestamp());
msgQosData.setPersistent(true);
this.topicEntry.setMsgUnit(msgUnit);
this.requestBroker.changePersistentTopicHandler(this.topicEntry);
}
}
else {
log.warning(ME+": Sorry we are in state '" + getStateStr() + "', reconfiguring TopicHandler is not yet supported, we ignore the reconfiguration request");
}
if (this.handlerIsNewCreated) {
this.handlerIsNewCreated = false;
// Check all known query subscriptions if the new message fits as well (does it only if TopicHandler is new)
serverScope.getRequestBroker().checkExistingSubscriptions(publisherSessionInfo, this, publishQosServer);
}
if (msgQosData.isFromPersistenceStore()) {
log.info(ME+": Topic is successfully recovered from persistency to state " + getStateStr() +
//((requestBroker.getTopicStore()!=null) ? (" '" + requestBroker.getTopicStore().getStorageId() + "'") : "") +
" with " + getNumOfHistoryEntries() + " history entries (" + getNumOfCacheEntries() + " currently referenced msgUnits are loaded).");
}
else {
log.info(ME+": Topic is successfully configured by administrative message.");
}
publishReturnQos.getData().setStateInfo("Administrative configuration request handled");
return publishReturnQos;
}
if (!this.administrativeInitialize) {
administrativeInitialize(msgKeyData, msgQosData, publishQosServer);
}
if (!isAlive()) {
toAlive();
}
if (this.handlerIsNewCreated) {
// Check all known query subscriptions if the new message fits as well (does it only if TopicHandler is new)
serverScope.getRequestBroker().checkExistingSubscriptions(publisherSessionInfo, this, publishQosServer);
this.handlerIsNewCreated = false;
}
int initialCounter = 1; // Force referenceCount until update queues are filled (volatile messages)
MsgUnitWrapper msgUnitWrapper = null;
try { // finally
boolean changed = true;
final boolean isInvisiblePtp = publishQosServer.isPtp() && !publishQosServer.isSubscribable();
final boolean addToHistoryQueue = this.historyQueue != null && !isInvisiblePtp;
if (!isInvisiblePtp) { // readonly is only checked for Pub/Sub?
if (this.topicProperty.isReadonly() && hasHistoryEntries()) {
log.warning(ME+": Sorry, published message '" + msgKeyData.getOid() + "' rejected, topic is readonly.");
throw new XmlBlasterException(serverScope, ErrorCode.USER_PUBLISH_READONLY, ME, "Sorry, published message '" + msgKeyData.getOid() + "' rejected, topic is readonly.");
}
}
msgUnitWrapper = new MsgUnitWrapper(serverScope, msgUnit, this.msgUnitCache, initialCounter, 0, -1);