示例#1
0
void ActiveMqProducer::sendMessage(const Destination* destination, const std::string& message, const std::string& correlation_id)
{
	MessageProducer* producer = session->createProducer(destination);
	producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT);
	TextMessage* text = session->createTextMessage(message);
	text->setCMSCorrelationID(correlation_id);
	producer->send(text);
}
void ServiceHandlerI::run() 
{
	Destination replyto;
	try
	{
		replyto = textmessage->getJMSReplyTo();
		if (!replyto)
		{
			serviceimplementor->doService(textmessage->getText());
		}
		else
		{
			if (logger->isLoggable(Level::FINEST)) logger->log(Level::FINEST, L"ServiceHandlerI::run() text: " + textmessage->getText());
			String replytext = serviceimplementor->doService(textmessage->getText());
			if (logger->isLoggable(Level::FINEST)) logger->log(Level::FINEST, L"ServiceHandlerI::run() replytext: " + replytext);
			TextMessage reply = queuesession->createTextMessage(replytext);

			Iterator<MapEntry<String, Anything> > i = serviceimplementor->getOutParameters()->entrySet()->iterator();
			while (i->hasNext())
			{
				MapEntry<String, Anything> current = i->next();
				reply->setStringProperty(current->key, current->value);
			}

			MessageProducer sender = queuesession->createProducer(replyto);
			sender->send(reply);
		}
	}
	catch (const Exception& e)
	{
		logger->log(Level::SEVERE, e->toString());
		if (!!replyto)
		{
			try
			{
				MessageProducer sender = queuesession->createProducer(replyto);
				sender->send(queuesession->createTextMessage(e->toString()));
			}
			catch (const Exception& e)
			{
				logger->log(Level::SEVERE, e->toString());
			}
		}
	}
}
bool MonitorPlugInActiveMQ::processResult(class ModuleResultBase *pRes)
{
	FILE_LOG(logDEBUG) << "apachemq: processing Result...";

	if (m_bConnected == false) {
		FILE_LOG(logERROR) << "apachmq: ignoring message 'cause no active connection";
		return false;
	}

	if (m_bTopicsInitialized == false) {
		throw RuntimeException(__FILE__, __LINE__, "processResult must be called AFTER initializeTopics()");
	}


	std::string type = (*pRes)["typ"];

	if (m_topics.find(type) == m_topics.end()) {
		FILE_LOG(logERROR) << "apachemq: received type " << type << " which is not registered";
		return false;
	}
	
	FILE_LOG(logINFO) << "Preparing new message";
	
	TopicInfo* topicInfo = (m_topics.find(type))->second;
	TextMessage* message = m_session->createTextMessage();

	ResultItemsMap::iterator i;

	for (i = (*pRes).m_Items.begin(); i != (*pRes).m_Items.end(); i++) {
		message->setStringProperty(i->first, i->second);
	}


	topicInfo->producer->send(message);
	
	FILE_LOG(logINFO) << "message sent";

	delete message;

	return true;
}
示例#4
0
void Engine::handleTextMessage(const TextMessage &message)
{
    sendMessageIgnoringError(
        AckMessage(message.getSenderId(), message.getTextId()));

    if (receiver->handleMessage(
        message.getSenderId(), message.getTextId())) {

        emit textReceived(message.getText(), message.getSenderNick());
    }
}
示例#5
0
void IRCChannelWidget::showMessage(const TextMessage& msg)
{
    QString message = QString::fromStdString(msg.toString());
    message = message.replace("&","&amp;").replace(">","&gt;").replace("<","&lt;");

    /* don't show commands (messages that start with '/') unless they are info messages, also if the user echo's back a message that the user sent
       in example in a private chat, don't show that*/

    /* messages that start with / are not shown unless they are info's and messages that
        come from a user with the same nick as the current user are not shown unless the messageType is set to OWNMESSAGE */
    if ((!msg.isCmd() || msg.getMessageType() == TextMessage::INFO) &&
            ((msg.getNick() != _client->getNick()) || (msg.getMessageType() == TextMessage::OWNMESSAGE))) {
        switch (msg.getMessageType(_client->getNick())) {
        case TextMessage::OWNMESSAGE:
        case TextMessage::STDMSG: {
            _msgScreen->appendHtml("<FONT COLOR=\"#000000\">" + message + "</FONT>");
            break;
        }
        case TextMessage::ERROR: {
            _msgScreen->appendHtml("<FONT COLOR=\"#ff0000\">" + message + "</FONT>");
            break;
        }
        case TextMessage::INFO: {
            _msgScreen->appendHtml("<FONT COLOR=\"#666666\">" + message + "</FONT>");
            break;
        }
        case TextMessage::DIRECTEDMSG: {
            _msgScreen->appendHtml("<FONT COLOR=\"#0000ff\">" + message + "</FONT>");
            break;
        }
        }
        // automatically scroll down
        QTextCursor c =  _msgScreen->textCursor();
        c.movePosition(QTextCursor::End);
        _msgScreen->setTextCursor(c);
        _msgScreen->ensureCursorVisible();
    }
}