*/
public void createFakedReturnObjects(I_QueueEntry[] entries, String state, String stateInfo) throws XmlBlasterException {
if (log.isLoggable(Level.FINER)) log.finer("Entering createFakedReturnObjects() for " + entries.length + " entries");
for (int ii=0; ii<entries.length; ii++) {
MsgQueueEntry msgQueueEntry = (MsgQueueEntry)entries[ii];
if (!msgQueueEntry.wantReturnObj())
continue;
StatusQosData statRetQos = new StatusQosData(glob, MethodName.UNKNOWN);
statRetQos.setStateInfo(stateInfo);
statRetQos.setState(state);
if (log.isLoggable(Level.FINE)) log.fine("Creating faked return for '" + msgQueueEntry.getMethodName() + "' invocation");
if (MethodName.PUBLISH_ONEWAY == msgQueueEntry.getMethodName()) {
MsgQueuePublishEntry entry = (MsgQueuePublishEntry)msgQueueEntry;
entry.setReturnObj(null);
}
else if (MethodName.PUBLISH == msgQueueEntry.getMethodName()) {
MsgQueuePublishEntry entry = (MsgQueuePublishEntry)msgQueueEntry;
if (!entry.getMsgKeyData().hasOid()) {
entry.getMsgKeyData().setOid(entry.getMsgKeyData().generateOid(entry.getSender().getRelativeName()));
}
statRetQos.setKeyOid(entry.getKeyOid());
PublishReturnQos publishReturnQos = new PublishReturnQos(glob, statRetQos);
//TODO: How to fake the RcvTimestamp -> it must be unique for an OID in the server
//publishReturnQos.getData().setRcvTimestamp(new org.xmlBlaster.util.RcvTimestamp());
entry.setReturnObj(publishReturnQos);
}
else if (MethodName.SUBSCRIBE == msgQueueEntry.getMethodName()) {
if (getDispatchManager().getSessionName().getPublicSessionId() < 1) {
// we should never allow a subscription without a positive sessionId if the
// server is not accessible
throw new XmlBlasterException(glob, ErrorCode.RESOURCE_TEMPORARY_UNAVAILABLE, ME,
"The Subscription for '" + getDispatchManager().getSessionName().toString() + "' failed since the server is currently not available");
}
MsgQueueSubscribeEntry entry = (MsgQueueSubscribeEntry)msgQueueEntry;
if (!entry.getSubscribeQosData().hasSubscriptionId()) {
entry.getSubscribeQosData().generateSubscriptionId(glob.getXmlBlasterAccess().getSessionName(), entry.getSubscribeKeyData());
//String subscriptionId = QueryKeyData.generateSubscriptionId(dispatchManager.getQueue().getStorageId().getPostfix());
//entry.getSubscribeQosData().setSubscriptionId(subscriptionId);
}
statRetQos.setSubscriptionId(entry.getSubscribeQosData().getSubscriptionId());
SubscribeReturnQos subscribeReturnQos = new SubscribeReturnQos(glob, statRetQos, true);
entry.setReturnObj(subscribeReturnQos);
}
else if (MethodName.UNSUBSCRIBE == msgQueueEntry.getMethodName()) {
MsgQueueUnSubscribeEntry entry = (MsgQueueUnSubscribeEntry)msgQueueEntry;
String id = entry.getUnSubscribeKey().getOid();
if (id != null && id.startsWith(Constants.SUBSCRIPTIONID_PREFIX)) {
statRetQos.setSubscriptionId(id);
UnSubscribeReturnQos[] unSubscribeReturnQosArr = new UnSubscribeReturnQos[] { new UnSubscribeReturnQos(glob, statRetQos) };
entry.setReturnObj(unSubscribeReturnQosArr);
}
else {
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME,
"UnSubscribe on oid='" + id + "' is not possible in offline/polling mode without an exact subscription ID given. " +
"See 'http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.failsafe.html' for more details.");
}
}
else if (MethodName.ERASE == msgQueueEntry.getMethodName()) {
MsgQueueEraseEntry entry = (MsgQueueEraseEntry)msgQueueEntry;
if (entry.getEraseKey().isExact()) {
statRetQos.setKeyOid(entry.getEraseKey().getOid());
EraseReturnQos[] eraseReturnQosArr = new EraseReturnQos[] { new EraseReturnQos(glob, statRetQos) };
entry.setReturnObj(eraseReturnQosArr);
}
else {
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME,
"Erase on oid='" + entry.getEraseKey().getOid() + "' is not possible in offline/polling mode without an exact topic oid given. " +
"See 'http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.failsafe.html' for more details.");
}
}
else if (MethodName.CONNECT == msgQueueEntry.getMethodName()) {
ConnectReturnQos connectReturnQos = new ConnectReturnQos(glob, ((MsgQueueConnectEntry)msgQueueEntry).getConnectQosData());
if (!connectReturnQos.getSessionName().isPubSessionIdUser()) {
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME,
"Can't find an xmlBlaster server. Try to provide the server host/port as described in " +
"http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.configuration.html " +
"or provide a public session ID to support polling for xmlBlaster without an initial connection. " +
"See 'http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.failsafe.html' for more details.");
}
msgQueueEntry.setReturnObj(connectReturnQos);
}
else if (MethodName.DISCONNECT == msgQueueEntry.getMethodName()) {
if (log.isLoggable(Level.FINE)) log.fine("disconnect returns void, nothing to do");
}
else if (MethodName.GET == msgQueueEntry.getMethodName()) {
MsgQueueGetEntry entry = (MsgQueueGetEntry)msgQueueEntry;
throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME,
"Synchronous GET on oid='" + entry.getGetKey().getOid() + "' is not possible in offline/polling mode. " +
"See 'http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.failsafe.html' for more details.");
}
else {
log.severe("Internal problem, MsgQueueEntry '" + msgQueueEntry.getEmbeddedType() + "' not expected here");
}
}
}