/** * Block until a message is received. * Hangs on the remote receive message call. * @return The next message. */ public Message receiveMessage() { Message message = null; try { message = m_receiveQueue.receiveRemoteMessage(); // Hang until a message comes through } catch (RemoteException ex) { ex.printStackTrace(); return null; // Remote exception = I'm done } if (message != null) ((BaseMessage)message).setProcessedByServer(true); // Don't send the message back down. return message; } }
/** * Free the receiver (and the remote session). */ public void free() { this.stopThisThread(); // This needs to be called first (even though super.free() calls it). super.free(); // Free all the filters next (This is also tell the remotesessions to clean up). if (m_receiveQueue != null) { try { m_receiveQueue.freeRemoteSession(); } catch (RemoteException ex) { ex.printStackTrace(); } } m_receiveQueue = null; } /**
if (RECEIVE_REMOTE_MESSAGE.equals(strCommand)) Message message = ((RemoteReceiveQueue)m_remoteObject).receiveRemoteMessage(); if (message != null) // If the client quits, this is freed and I get a null message (which I don't need to return) this.setReturnObject(out, message); objReturn = ((RemoteReceiveQueue)m_remoteObject).addRemoteMessageFilter(messageFilter, remoteSession); objReturn = ((RemoteReceiveQueue)m_remoteObject).addRemoteMessageFilter(messageFilter, null); boolean bSuccess = ((RemoteReceiveQueue)m_remoteObject).removeRemoteMessageFilter(messageFilter, bFreeFilter); this.setReturnObject(out, new Boolean(bSuccess)); Object[][] propIn = (Object[][])this.getNextObjectParam(in, PROPERTIES, properties); Map<String,Object> propFilter = this.getNextPropertiesParam(in, MAP, properties); ((RemoteReceiveQueue)m_remoteObject).updateRemoteFilterProperties(messageFilter, propIn, propFilter);
/** * Remove this message filter from this queue. * Also remove the remote message filter. * @param messageFilter The message filter to remove. * @param bFreeFilter If true, free this filter. * @return True if successful. */ public boolean removeMessageFilter(MessageFilter messageFilter, boolean bFreeFilter) { boolean bSuccess = false; try { if (((BaseMessageFilter)messageFilter).getRemoteFilterID() == null) bSuccess = true; // No remote filter to remove else bSuccess = m_receiveQueue.removeRemoteMessageFilter((BaseMessageFilter)messageFilter, bFreeFilter); } catch (RemoteException ex) { ex.printStackTrace(); } if (!bSuccess) Util.getLogger().warning("Remote listener not removed"); // Never return super.removeMessageFilter(messageFilter, bFreeFilter); } /**
/** * Update this filter with this new information. * Override this to do something if there is a remote version of this filter. * @param messageFilter The message filter I am updating. * @param properties New filter information (ie, bookmark=345). */ public void setNewFilterProperties(BaseMessageFilter messageFilter, Object[][] mxProperties, Map<String, Object> propFilter) { super.setNewFilterProperties(messageFilter, mxProperties, propFilter); // Does nothing. try { if (messageFilter.isUpdateRemoteFilter()) // Almost always true if (messageFilter.getRemoteFilterID() != null) // If the remote filter exists m_receiveQueue.updateRemoteFilterProperties(messageFilter, mxProperties, propFilter); } catch (RemoteException ex) { ex.printStackTrace(); } } /**
/** * Add this message filter to this receive queue. * Also adds a message filter to the remote queue. * @param The message filter to add. * @return The message filter passed in. */ public void addMessageFilter(MessageFilter messageFilter) { super.addMessageFilter(messageFilter); try { // If at all possible, pass the queue's current session, so the filter is in the proper environment if (((BaseMessageFilter)messageFilter).isCreateRemoteFilter()) // Almost always true { // Create the remote version of this filter. RemoteSession remoteSession = (RemoteSession)((BaseMessageFilter)messageFilter).getRemoteSession(); BaseMessageFilter remoteFilter = m_receiveQueue.addRemoteMessageFilter((BaseMessageFilter)messageFilter, remoteSession); ((BaseMessageFilter)messageFilter).setRemoteFilterInfo(remoteFilter.getQueueName(), remoteFilter.getQueueType(), remoteFilter.getFilterID(), remoteFilter.getRegistryID()); } } catch (RemoteException ex) { ex.printStackTrace(); } } /**
/** * Block until a message is received. * Hangs on the remote receive message call. * @return The next message. */ public Message receiveMessage() { Message message = null; try { message = m_receiveQueue.receiveRemoteMessage(); // Hang until a message comes through } catch (RemoteException ex) { ex.printStackTrace(); return null; // Remote exception = I'm done! } if (message instanceof BaseMessage) ((BaseMessage)message).setProcessedByServer(true); // Don't send the message back down. return message; } /**