Constructor.
@param server The remote server.
@param baseMessageQueue My parent message queue.
964003
public void init(RemoteTask server, BaseMessageQueue baseMessageQueue)
        throws RemoteException
    {
        super.init(baseMessageQueue);
        m_receiveQueue = server.createRemoteReceiveQueue(baseMessageQueue.getQueueName(), baseMessageQueue.getQueueType());
    }
1172573
public BaseMessageSender createMessageSender()
    {
        RemoteTask server = (RemoteTask)((App)this.getMessageManager().getApplication()).getRemoteTask(null);
        try   {
            return new RemoteMessageSender(server, this);
        } catch (RemoteException ex)    {
            ex.printStackTrace();
        }
        return null;
    }
268689
public Message onMessage(final Message message, final String type, final String tenant, final String virtualHost) {
        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(tenant)) {
            throw new AmqpRejectAndDontRequeueException("Invalid message! tenant and type header are mandatory!");
        }

        final SecurityContext oldContext = SecurityContextHolder.getContext();
        try {
            final MessageType messageType = MessageType.valueOf(type);
            switch (messageType) {
            case THING_CREATED:
                setTenantSecurityContext(tenant);
                registerTarget(message, virtualHost);
                break;
            case EVENT:
                checkContentTypeJson(message);
                setTenantSecurityContext(tenant);
                handleIncomingEvent(message);
                break;
            case PING:
                if (isCorrelationIdNotEmpty(message)) {
                    amqpMessageDispatcherService.sendPingReponseToDmfReceiver(message, tenant, virtualHost);
                }
                break;
            default:
                logAndThrowMessageError(message, "No handle method was found for the given message type.");
            }
        } catch (final IllegalArgumentException ex) {
            throw new AmqpRejectAndDontRequeueException("Invalid message!", ex);
        } finally {
            SecurityContextHolder.setContext(oldContext);
        }
        return null;
    }
440906
public BaseMessage processMessage(BaseMessage internalMessage)
    {
        if (internalMessage.getMessageDataDesc(null) == null)
            internalMessage.addMessageDataDesc(new RunRemoteProcessMessageData(null, null));
        
        RunRemoteProcessMessageData runRemoteProcessMessageData = (RunRemoteProcessMessageData)internalMessage.getMessageDataDesc(null);
        String processClassName = (String)runRemoteProcessMessageData.get(RunRemoteProcessMessageData.PROCESS_CLASS_NAME);
        if (processClassName == null)
        	return null;
        
        BaseProcess process = null;
        Task task = this.getTask();
        Map<String,Object> properties = new HashMap<String,Object>();
        MapMessage.convertDOMtoMap(internalMessage.getDOM(), properties, true);
        process = (BaseProcess)ClassServiceUtility.getClassService().makeObjectFromClassName(processClassName);
        if (process == null)
        	return null;
        process.init(task, null, properties);
        
        BaseMessage messageReply = null;
        if (process instanceof BaseMessageProcess)
        	messageReply = ((BaseMessageProcess)process).processMessage(internalMessage);
        else
        	process.run();
      
        return messageReply;
    }
1193215
public void init(BaseMessage message, Object objRawMessage)
    {
        m_message = message;
        if (message != null)
            message.setExternalMessage(this);
        if (objRawMessage != null)
            this.setRawData(objRawMessage);
    }
628431
@Override
	public synchronized QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException
    {
        checkNotClosed();
        LocalQueueSession session =  new LocalQueueSession(idProvider.createID(),this,engine,transacted,acknowledgeMode);
        registerSession(session);
        return session;
    }
421017
public void init(BaseMessageReceiver messageReceiver, BaseMessageFilter messageFilter)
    {
        if (messageFilter == null)
        {
            if (messageReceiver != null)
            {
                messageFilter = messageReceiver.createDefaultFilter(this);    // Add filter to handler
                return; // All done. (createDefaultFilter adds the message listener to the new filter)
            }
        }
        if (messageFilter != null)
            messageFilter.addMessageListener(this);     // This will also add the message filter to my list.
    }
1324729
protected void putToQueue(IQueueMessage<ID, DATA> msg) throws QueueException.QueueIsFull {
        if (!queue.offer(msg)) {
            throw new QueueException.QueueIsFull(getBoundary());
        }
    }
490897
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);
    }
953817
public void sendConsoleMessage(Level level, String msg) {
        if (!(getServerCaller() instanceof UnitTestServerCaller)) {
            getLogger().log(level, msg);
        }
    }
781412
public int sendMessage(Message message)
    {
        BaseMessageHeader messageHeader = ((BaseMessage)message).getMessageHeader();
        String strQueueType = messageHeader.getQueueType();
        String strQueueName = messageHeader.getQueueName();
        MessageSender sender = this.getMessageQueue(strQueueName, strQueueType).getMessageSender();
        if (sender != null)
            sender.sendMessage(message);
        else
            return Constant.ERROR_RETURN;  // Queue doesn't exist
        return Constant.NORMAL_RETURN;
    }
199201
protected void addMessage(String message)
    {
        messages.add(message);
        messageCount++;
        if (messageCount > messagesQueueMax)
        {
            messages.remove();
            messageCount--;
        }
    }
105564
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;
    }
982828
public void enqueue(TaskMessage message, Channel channel) {
        // lots of messages may be lost when deserialize queue hasn't finished init operation
        while (!bstartRec) {
            LOG.info("check whether deserialize queues have already been created");
            boolean isFinishInit = true;
            for (Integer task : workerTasks) {
                if (deserializeQueues.get(task) == null) {
                    isFinishInit = false;
                    JStormUtils.sleepMs(10);
                    break;
                }
            }
            if (isFinishInit) {
                bstartRec = isFinishInit;
            }
        }
        short type = message.get_type();
        if (type == TaskMessage.NORMAL_MESSAGE) {
            // 
            int task = message.task();
            DisruptorQueue queue = deserializeQueues.get(task);
            if (queue == null) {
                LOG.warn("Received invalid message directed at task {}. Dropping...", task);
                LOG.debug("Message data: {}", JStormUtils.toPrintableString(message.message()));
                return;
            }
            if (!isBackpressureEnable) {
                queue.publish(message.message());
            } else {
                flowCtrlHandler.flowCtrl(channel, queue, task, message.message());
            }
        } else if (type == TaskMessage.CONTROL_MESSAGE) {
            // enqueue a control message
            if (recvControlQueue == null) {
                LOG.info("Can not find the recvControlQueue. Dropping this control message");
                return;
            }
            recvControlQueue.publish(message);
        } else {
            LOG.warn("Unexpected message (type={}) was received from task {}", type, message.task());
        }
    }
448207
@Inject
    public void setQueue(EventQueue queue) {
        if (epi == null) {
            MessageToEventMapper mapper = new MessageToEventMapper();
            mapper.setMaxContentLength(maxContentLength);

            epi = new EventProducerInterceptor(mapper, queue);
        }
    }
624829
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();
        }
    }
887618
@Override
    public void prepare ( CommonServerMessageBlockRequest next ) {
        if ( isReceived() ) {
            ( (ServerMessageBlock2) next ).setTreeId(getTreeId());
        }
        super.prepare(next);
    }