/** * 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; } /**
/** * 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; } /**
/** * 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; } /**
/** * StartProcess Method. */ public void startProcess(String strProcessName, int iCount) { Map<String,Object> properties = new HashMap<String,Object>(); properties.put(DBParams.PROCESS, strProcessName); properties.put(DBParams.TABLE, this.getProperty(DBParams.TABLE)); properties.put("count", iCount); Application app = (Application)this.getTask().getApplication(); String strQueueName = MessageConstants.TRX_SEND_QUEUE; String strQueueType = MessageConstants.INTRANET_QUEUE; BaseMessage message = new MapMessage(new TrxMessageHeader(strQueueName, strQueueType, properties), properties); app.getMessageManager().sendMessage(message); }
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { String strRoomType = (String)internalMessage.get("rateType"); String strRoomClass = (String)internalMessage.get("roomClass"); // Add code to lookup hotel rate here try { java.lang.Thread.currentThread().sleep(5000); // Simulate time for message turnaround } catch (InterruptedException ex) { } BaseMessage replyMessage = new MapMessage(); replyMessage.put(DBParams.FIELD, "multipleFields"); replyMessage.put("CityOrTown", "Los Angeles"); replyMessage.put("Contact", "Fred"); //? this.sendMessage(new BaseMessage(null, replyMessage)); return null; // No reply expected }
/** * Stop this thread. */ public void stopThisThread() { super.stopThisThread(); // Set the flag to stop this thread. // Now, send a message which will be received by this thread; since continueLooping is off, this thread will stop. ((LocalMessageQueue)this.getMessageQueue()).getMessageStack().sendMessage(new MapMessage(null, null)); } /**
/** * RunUpdater Method. */ public boolean runUpdater() { Map<String,Object> properties = new HashMap<String,Object>(); String strTableName = this.getMainRecord().getTableNames(false); properties.put(DBParams.PROCESS, HotelAvailProcess.class.getName()); properties.put(DBParams.TABLE, strTableName); Application app = (Application)this.getTask().getApplication(); String strQueueName = MessageConstants.TRX_SEND_QUEUE; String strQueueType = MessageConstants.INTRANET_QUEUE; BaseMessage message = new MapMessage(new TrxMessageHeader(strQueueName, strQueueType, properties), properties); app.getMessageManager().sendMessage(message); return true; }
/** * Process this internal message. * @param internalMessage The message to process. * @return (optional) The return message if applicable. */ public BaseMessage processMessage(BaseMessage internalMessage) { String strRoomType = (String)internalMessage.get("rateType"); String strRoomClass = (String)internalMessage.get("roomClass"); // Add code to lookup hotel rate here try { java.lang.Thread.currentThread().sleep(5000); // Simulate time for message turnaround } catch (InterruptedException ex) { } BaseMessage replyMessage = new MapMessage(); replyMessage.put(DBParams.FIELD, "multipleFields"); replyMessage.put("CityOrTown", "Los Angeles"); replyMessage.put("Contact", "Fred"); //? this.sendMessage(new BaseMessage(null, replyMessage)); return null; // No reply expected }
public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); if ((iChangeType == DBConstants.AFTER_ADD_TYPE) || (iChangeType == DBConstants.AFTER_UPDATE_TYPE)) if (!getField(AnnivMaster.kProperties).isNull()) { // This will cause the JobScheduler to reschedule the jobs (now that they have changed) BaseMessageManager messageManager = ((Application)getTask().getApplication()).getMessageManager(); Map<String,Object> properties = new Hashtable<String,Object>(); properties.put(DBParams.PROCESS, JobSchedulerReference.JOB_PROCESS_NAME); if (messageManager != null) messageManager.sendMessage(new MapMessage(new BaseMessageHeader(CalendarEntry.JOB_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, this, null), properties)); } return iErrorCode; } });
properties.put(DBParams.PROCESS, MessageTimeoutProcess.class.getName()); if (messageManager != null) messageManager.sendMessage(new MapMessage(new BaseMessageHeader(MessageTimeoutProcess.TIMEOUT_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, this, null), properties));
/** * 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) { System.out.println("---------------------------------------------------------- HotelSession/86"); if (message instanceof BaseMessage) { Double dblRate = (Double)message.get(BookingDetail.TOTAL_COST); if (message.get(HotelRateResponse.PRODUCT_RESPONSE_MESSAGE) instanceof HotelRateResponseMessageData) { dblRate = new Double(((HotelRateResponseMessageData)message.get(HotelRateResponse.PRODUCT_RESPONSE_MESSAGE)).getRoomCost(PaxCategory.DOUBLE_ID)); } MessageManager messageManager = ((Application)this.getTask().getApplication()).getMessageManager(); BaseMessageHeader messageFilter = message.getMessageHeader(); BaseMessageHeader messageHeader = new SessionMessageHeader(null, this); Map<String,Object> properties = new Hashtable<String,Object>(); properties.put("hotelCost", dblRate); BaseMessage messageTableUpdate = new MapMessage(messageHeader, properties); messageManager.sendMessage(messageTableUpdate); } return super.handleMessage(message); }
public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions) { Task task = getTask(); Application application = (Application)task.getApplication(); String strQueueName = getProperty(MessageConstants.QUEUE_NAME); MessageManager messageManager = application.getMessageManager(); Map<String,Object> propHeader = new Hashtable<String,Object>(); Map<String,Object> propMessage = new Hashtable<String,Object>(); Record record = getParentScreen().getMainRecord(); if ((record.getEditMode() == DBConstants.EDIT_CURRENT) || (record.getEditMode() == DBConstants.EDIT_IN_PROGRESS)) { String bookmark = null; try { bookmark = record.getHandle(DBConstants.OBJECT_ID_HANDLE).toString(); } catch (DBException ex) { ex.printStackTrace(); } propMessage.put(RecordMessageConstants.TABLE_NAME, record.getTableNames(false)); propMessage.put(DBConstants.STRING_OBJECT_ID_HANDLE, bookmark); BaseMessageHeader messageHeader = new BaseMessageHeader(strQueueName, MessageConstants.INTRANET_QUEUE, this, propHeader); BaseMessage message = new MapMessage(messageHeader, propMessage); messageManager.sendMessage(message); } return super.doCommand(strCommand, sourceSField, iCommandOptions); } };
public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); if ((iChangeType == DBConstants.AFTER_ADD_TYPE) || (iChangeType == DBConstants.AFTER_UPDATE_TYPE)) if (getSharedRecordTypeKey().getValue() == CalendarEntry.APPOINTMENT_ID) if (!getField(CalendarEntry.kProperties).isNull()) { // This will cause the JobScheduler to reschedule the jobs (now that they have changed) BaseMessageManager messageManager = ((Application)getTask().getApplication()).getMessageManager(); Map<String,Object> properties = new Hashtable<String,Object>(); properties.put(DBParams.PROCESS, JobSchedulerReference.JOB_PROCESS_NAME); if (messageManager != null) messageManager.sendMessage(new MapMessage(new BaseMessageHeader(JOB_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, this, null), properties)); } return iErrorCode; } });
public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions) { Task task = getTask(); Application application = (Application)task.getApplication(); String strQueueName = getProperty(MessageConstants.QUEUE_NAME); MessageManager messageManager = application.getMessageManager(); Map<String,Object> propHeader = new Hashtable<String,Object>(); Map<String,Object> propMessage = new Hashtable<String,Object>(); Record record = getParentScreen().getMainRecord(); if ((record.getEditMode() == DBConstants.EDIT_CURRENT) || (record.getEditMode() == DBConstants.EDIT_IN_PROGRESS)) { String bookmark = null; try { bookmark = record.getHandle(DBConstants.OBJECT_ID_HANDLE).toString(); } catch (DBException ex) { ex.printStackTrace(); } propMessage.put(RecordMessageConstants.TABLE_NAME, record.getTableNames(false)); propMessage.put(DBConstants.STRING_OBJECT_ID_HANDLE, bookmark); BaseMessageHeader messageHeader = new BaseMessageHeader(strQueueName, MessageConstants.INTRANET_QUEUE, this, propHeader); BaseMessage message = new MapMessage(messageHeader, propMessage); messageManager.sendMessage(message); } return super.doCommand(strCommand, sourceSField, iCommandOptions); } };
Map<String,Object> map = new Hashtable<String,Object>(); map.put(DBConstants.OBJECT_ID, this.getProperty(DBConstants.OBJECT_ID)); BaseMessage message = new MapMessage(messageHeader, map);
/** * 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 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; } }
properties.put(DBParams.PROCESS, MessageTimeoutProcess.class.getName()); if (messageManager != null) messageManager.sendMessage(new MapMessage(new BaseMessageHeader(MessageTimeoutProcess.TIMEOUT_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, this, null), properties));
String strQueueName = MessageConstants.TRX_SEND_QUEUE; String strQueueType = MessageConstants.INTRANET_QUEUE; BaseMessage message = new MapMessage(new TrxMessageHeader(strQueueName, strQueueType, properties), properties); String strProcess = Utility.propertiesToURL(null, properties);
/** * RegisterProcessForMessage Method. */ public void registerProcessForMessage(BaseMessageFilter messageFilter, String strProcessClass, Map<String,Object> properties) { new TrxMessageListener(messageFilter, (Application)this.getTask().getApplication(), strProcessClass, properties); // This listener was added to the filter ((MessageInfoApplication)this.getTask().getApplication()).getThickMessageManager().addMessageFilter(messageFilter); // Note: No need to worry about cleanup... Freeing the message manager will free all these listeners. if (properties != null) if (properties.get(MessageInfoApplication.AUTOSTART) != null) ((MessageInfoApplication)this.getTask().getApplication()).getThickMessageManager().sendMessage(new MapMessage(new BaseMessageHeader(messageFilter.getQueueName(), messageFilter.getQueueType(), this, null), properties)); }