/** * Return the state of this object as a properties object. * @param strKey The key to return. * @return The properties. */ public Object get(String strKey) { Object objData = super.get(strKey); if (objData == null) if (m_mapMessageHeader != null) objData = m_mapMessageHeader.get(strKey); if (objData == null) if (m_mapMessageInfo != null) objData = m_mapMessageInfo.get(strKey); if (objData == null) if (m_mapMessageTransport != null) objData = m_mapMessageTransport.get(strKey); return objData; } /**
/** * Don't create a new object each time. * @return */ public BaseMessage getMessageObject() { if (m_message == null) { Map<String,Object> properties = new Hashtable<String,Object>(); m_message = new MapMessage(new BaseMessageHeader(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE, this, null), properties); } return m_message; } /**
/** * Free this object. */ public void free() { super.free(); } /**
String strQueueType = messageHeader.getQueueType(); String strQueueName = messageHeader.getQueueName(); if (MessageConstants.LOCAL_QUEUE.equalsIgnoreCase(strQueueType)) if (MessageTransportModel.DIRECT.equalsIgnoreCase((String)messageHeader.get(MessageTransportModel.SEND_MESSAGE_BY_PARAM)))
if (m_properties.get("standalone") == null) if ((message.getMessageHeader().get(REMOVE_LISTENER) != null) || (message.get(REMOVE_LISTENER) != null)) m_properties.put(MessageConstants.QUEUE_NAME, message.getMessageHeader().getQueueName()); if (m_properties.get(MessageConstants.QUEUE_TYPE) == null) m_properties.put(MessageConstants.QUEUE_TYPE, message.getMessageHeader().getQueueType()); m_properties.remove(ServletTask.APPLICATION); m_properties.remove(MessageInfoApplication.AUTOSTART); properties.remove(MessageInfoApplication.AUTOSTART); properties.put(DBParams.PROCESS, strProcessClass); BaseMessage messageInitial = new MapMessage(new BaseMessageHeader(message.getMessageHeader().getQueueName(), message.getMessageHeader().getQueueType(), this, null), properties); env.getMessageManager(m_application, true).sendMessage(messageInitial); // Resend it! (Don't consume it!)
String strMessage = (String)message.get("message"); BaseMessageHeader messageHeader = message.getMessageHeader(); String strQueueName = messageHeader.getQueueName(); String strQueueType = messageHeader.getQueueType(); Integer intRegID = messageHeader.getRegistryIDMatch(); JSONObject jsonObj = new JSONObject();
/** * If you are sending a thick message to a thin client, convert it first. * Since BaseMessage is already, so conversion is necessary... return this message. * @return this message. */ public BaseMessage convertToThinMessage() { int iChangeType = ((RecordMessageHeader)this.getMessageHeader()).getRecordMessageType(); // See if this record is currently displayed or buffered, if so, refresh and display. Object data = this.getData(); BaseMessage messageTableUpdate = null; // NOTE: The only way I will send this message to the client is if the ModelMessageHandler.START_INDEX_PARAM has been added to this message by the TableSession // if (properties.get(ModelMessageHandler.START_INDEX_PARAM) != null) { BaseMessageHeader messageHeader = new SessionMessageHeader(this.getMessageHeader().getQueueName(), this.getMessageHeader().getQueueType(), null, this); messageTableUpdate = new MapMessage(messageHeader, data); messageTableUpdate.put(MessageConstants.MESSAGE_TYPE_PARAM, Integer.toString(iChangeType)); } return messageTableUpdate; } }
if (ModifyTourSubField.SELECT_QUEUE.equals(message.getMessageHeader().getQueueName()))
/** * A record with this datasource handle changed, notify any behaviors that are checking. * NOTE: Be very careful as this code is running in an independent thread * (synchronize to the task before calling record calls). * NOTE: For now, you are only notified of the main record changes. * @param message The message to handle. * @return The error code. */ public int handleMessage(BaseMessage message) { if (message != null) if (message.getMessageHeader().getRegistryIDMatch() != null) // My private message if (message.getMessageHeader().getRegistryIDMatch().equals(m_intRegistryID)) // My private message { Application app = (Application)this.getTask().getApplication(); String strMessage = app.getResources(ResourceConstants.DEFAULT_RESOURCE, true).getString("Remote action completed"); this.getTask().setStatusText(strMessage, Constants.INFORMATION); message.consume(); } return super.handleMessage(message); }
/** * Send this message to the remote send queue (who will pass it on). * @param message The message to send. */ public void sendMessage(Message message) { try { if (((RemoteMessageQueue)this.getMessageQueue()).isSendRemoteMessage((BaseMessage)message) == false) return; if (((BaseMessage)message).isProcessedByServer()) return; // Don't send back down (the server already processed it). if (((BaseMessage)message).isConsumed()) return; // Don't send if already handled. if (MessageConstants.LOCAL_QUEUE.equalsIgnoreCase(((BaseMessage)message).getMessageHeader().getQueueType())) return; // Local queue only synchronized (m_sendQueue) { // In case this is called from another task m_sendQueue.sendMessage(message); } } catch (RemoteException ex) { ex.printStackTrace(); } } }
/** * Constructor. * @param strQueueName Name of the queue. * @param strQueueType Type of queue - remote or local. * @param source usually the object sending or listening for the message, to reduce echos. */ public void init(String strQueueName, String strQueueType, Object source, Map<String,Object> properties) { m_mapMessageHeader = properties; m_mapMessageTransport = null; m_mapMessageInfo = null; super.init(strQueueName, MessageConstants.INTERNET_QUEUE, source, properties); } /**
/** * Return the state of this object as a properties object. * @return The properties. */ public Map<String,Object> getProperties() { Map<String,Object> properties = super.getProperties(); if (m_mapMessageHeader != null) properties.putAll(m_mapMessageHeader); if (m_mapMessageInfo != null) properties.putAll(m_mapMessageInfo); if (m_mapMessageTransport != null) properties.putAll(m_mapMessageTransport); return properties; } /**
strReturnQueueName = MessageConstants.TRX_RETURN_QUEUE; TrxMessageHeader privateMessageHeader = new TrxMessageHeader(strReturnQueueName, MessageConstants.INTERNET_QUEUE, null); if (message.getMessageHeader().getRegistryIDMatch() == null) message.getMessageHeader().setRegistryIDMatch(intRegistryID); privateMessageHeader.setRegistryIDMatch(message.getMessageHeader().getRegistryIDMatch()); message.setMessageHeader(privateMessageHeader);
String strQueueType = messageHeader.getQueueType(); String strQueueName = messageHeader.getQueueName(); if (MessageConstants.LOCAL_QUEUE.equalsIgnoreCase(strQueueType)) if (MessageTransport.DIRECT.equalsIgnoreCase((String)messageHeader.get(MessageTransport.SEND_MESSAGE_BY_PARAM)))
if (m_properties.get("standalone") == null) if ((message.getMessageHeader().get(REMOVE_LISTENER) != null) || (message.get(REMOVE_LISTENER) != null)) m_properties.put(MessageConstants.QUEUE_NAME, message.getMessageHeader().getQueueName()); if (m_properties.get(MessageConstants.QUEUE_TYPE) == null) m_properties.put(MessageConstants.QUEUE_TYPE, message.getMessageHeader().getQueueType()); m_properties.remove(DBParams.APPLICATION); m_properties.remove(MessageApplication.AUTOSTART); properties.remove(MessageApplication.AUTOSTART); properties.put(DBParams.PROCESS, strProcessClass); BaseMessage messageInitial = new MapMessage(new BaseMessageHeader(message.getMessageHeader().getQueueName(), message.getMessageHeader().getQueueType(), this, null), properties); env.getMessageManager(m_application, true).sendMessage(messageInitial); // Resend it! (Don't consume it!)
/** * If you are sending a thick message to a thin client, convert it first. * Since BaseMessage is already, so conversion is necessary... return this message. * @return this message. */ public BaseMessage convertToThinMessage() { int iChangeType = ((RecordMessageHeader)this.getMessageHeader()).getRecordMessageType(); // See if this record is currently displayed or buffered, if so, refresh and display. Object data = this.getData(); BaseMessage messageTableUpdate = null; // NOTE: The only way I will send this message to the client is if the ModelMessageHandler.START_INDEX_PARAM has been added to this message by the TableSession // if (properties.get(ModelMessageHandler.START_INDEX_PARAM) != null) { BaseMessageHeader messageHeader = new SessionMessageHeader(this.getMessageHeader().getQueueName(), this.getMessageHeader().getQueueType(), null, this); messageTableUpdate = new MapMessage(messageHeader, data); messageTableUpdate.put(MessageConstants.MESSAGE_TYPE_PARAM, Integer.toString(iChangeType)); } return messageTableUpdate; } }
if (ModifyTourSubField.SELECT_QUEUE.equals(message.getMessageHeader().getQueueName()))
/** * A record with this datasource handle changed, notify any behaviors that are checking. * NOTE: Be very careful as this code is running in an independent thread * (synchronize to the task before calling record calls). * NOTE: For now, you are only notified of the main record changes. * @param message The message to handle. * @return The error code. */ public int handleMessage(BaseMessage message) { if (message != null) if (message.getMessageHeader().getRegistryIDMatch() != null) // My private message if (message.getMessageHeader().getRegistryIDMatch().equals(m_intRegistryID)) // My private message { Application app = (Application)this.getTask().getApplication(); String strMessage = app.getResources(ResourceConstants.DEFAULT_RESOURCE, true).getString("Remote action completed"); this.getTask().setStatusText(strMessage, Constants.INFORMATION); message.consume(); } return super.handleMessage(message); }
/** * Constructor. * @param strQueueName Name of the queue. * @param strQueueType Type of queue - remote or local. * @param source usually the object sending or listening for the message, to reduce echos. */ public void init(String strQueueName, String strQueueType, Object source, Map<String,Object> properties) { m_mapMessageHeader = properties; m_mapMessageTransport = null; m_mapMessageInfo = null; super.init(strQueueName, MessageConstants.INTERNET_QUEUE, source, properties); } /**
/** * Return the state of this object as a properties object. * @return The properties. */ public Map<String,Object> getProperties() { Map<String,Object> properties = super.getProperties(); if (m_mapMessageHeader != null) properties.putAll(m_mapMessageHeader); if (m_mapMessageInfo != null) properties.putAll(m_mapMessageInfo); if (m_mapMessageTransport != null) properties.putAll(m_mapMessageTransport); return properties; } /**