Search in sources :

Example 6 with MessageProducer

use of com.creditease.uav.messaging.api.MessageProducer in project uavstack by uavorg.

the class AbstractPublishHandler method handle.

@Override
public void handle(List<T> mdflist) {
    MessageProducer producer = (MessageProducer) this.getComponentResource("messageproducer", "MessageProducerResourceComponent");
    Message msg = MessagingFactory.createMessage(getMessageKey());
    String stream = toJSONString(mdflist);
    msg.setParam(getMessageKey(), stream);
    boolean check = producer.submit(msg);
    String sendState = getMessageKey() + " Data Sent " + (check ? "SUCCESS" : "FAIL");
    if (log.isTraceEnable()) {
        log.info(this, sendState + "	" + stream);
    }
}
Also used : Message(com.creditease.uav.messaging.api.Message) MessageProducer(com.creditease.uav.messaging.api.MessageProducer)

Example 7 with MessageProducer

use of com.creditease.uav.messaging.api.MessageProducer in project uavstack by uavorg.

the class MonitorScheduleWorker method executeTestCase.

@Override
public void executeTestCase() {
    MessageProducer producer = (MessageProducer) this.getComponentResource("messageproducer", "MessageProducerResourceComponent");
    // submit Monitor data
    Message msg = MessagingFactory.createMessage(MonitorDataFrame.MessageType.Monitor.toString());
    String stream = prepareTestData(testcase1);
    msg.setParam(MonitorDataFrame.MessageType.Monitor.toString(), stream);
    boolean check = producer.submit(msg);
    String sendState = "Monitor" + (check ? "SUCCESS" : "FAIL");
    if (log.isTraceEnable()) {
        log.info(this, sendState + "    " + stream);
    }
}
Also used : Message(com.creditease.uav.messaging.api.Message) MessageProducer(com.creditease.uav.messaging.api.MessageProducer)

Example 8 with MessageProducer

use of com.creditease.uav.messaging.api.MessageProducer in project uavstack by uavorg.

the class MonitorDataMessageHandler method handle.

@Override
public void handle(Message msg) {
    super.handle(msg);
    // NOW, we send out the MDF for runtime notification
    AgentResourceComponent arc = (AgentResourceComponent) ConfigurationManager.getInstance().getComponent("messageproducer", "MessageProducerResourceComponent");
    MessageProducer producer = (MessageProducer) arc.getResource();
    if (producer != null) {
        String runtimeKey = MonitorDataFrame.MessageType.RuntimeNtf.toString();
        Message rtntfmsg = MessagingFactory.createMessage(runtimeKey);
        String dataStream = msg.getParam(this.getMsgTypeName());
        rtntfmsg.setParam(runtimeKey, dataStream);
        boolean check = producer.submit(rtntfmsg);
        String sendState = runtimeKey + " Data Sent " + (check ? "SUCCESS" : "FAIL");
        if (log.isDebugEnable()) {
            log.debug(this, sendState + "    " + dataStream);
        }
    }
}
Also used : Message(com.creditease.uav.messaging.api.Message) AgentResourceComponent(com.creditease.agent.spi.AgentResourceComponent) MessageProducer(com.creditease.uav.messaging.api.MessageProducer)

Example 9 with MessageProducer

use of com.creditease.uav.messaging.api.MessageProducer in project uavstack by uavorg.

the class NodeInfoDataMessageHandler method handle.

@Override
public void handle(Message msg) {
    super.handle(msg);
    // NOW, we send out the MDF for runtime notification
    AgentResourceComponent arc = (AgentResourceComponent) ConfigurationManager.getInstance().getComponent("messageproducer", "MessageProducerResourceComponent");
    MessageProducer producer = (MessageProducer) arc.getResource();
    if (producer != null) {
        String runtimeKey = MonitorDataFrame.MessageType.RuntimeNtf.toString();
        Message rtntfmsg = MessagingFactory.createMessage(runtimeKey);
        String dataStream = msg.getParam(this.getMsgTypeName());
        rtntfmsg.setParam(runtimeKey, dataStream);
        boolean check = producer.submit(rtntfmsg);
        String sendState = runtimeKey + " Data Sent " + (check ? "SUCCESS" : "FAIL");
        if (log.isDebugEnable()) {
            log.debug(this, sendState + "    " + dataStream);
        }
    }
}
Also used : Message(com.creditease.uav.messaging.api.Message) AgentResourceComponent(com.creditease.agent.spi.AgentResourceComponent) MessageProducer(com.creditease.uav.messaging.api.MessageProducer)

Example 10 with MessageProducer

use of com.creditease.uav.messaging.api.MessageProducer in project uavstack by uavorg.

the class AppServerLogPublishWorkerByStream method handle.

@Override
protected void handle(List<String> streamList) {
    MessageProducer producer = (MessageProducer) this.getComponentResource("messageproducer", "MessageProducerResourceComponent");
    // submit profile data
    Message msg = MessagingFactory.createMessage(MonitorDataFrame.MessageType.Log.toString());
    for (String stream : streamList) {
        msg.setParam(MonitorDataFrame.MessageType.Log.toString(), stream);
        if (log.isDebugEnable()) {
            log.debug(this, "## final stream length ## : " + stream.getBytes().length);
            log.debug(this, "## final stream value ## : " + stream);
        }
        /**
         * TestUsage: output the result
         */
        // IOHelper.write(stream, "" + this.toString());
        producer.setLogger(log);
        boolean check = producer.submit(msg);
        String sendState = "Log Data Sent " + (check ? "SUCCESS" : "FAIL");
        if (log.isDebugEnable()) {
            log.debug(this, sendState + " " + stream);
        }
    }
}
Also used : Message(com.creditease.uav.messaging.api.Message) MessageProducer(com.creditease.uav.messaging.api.MessageProducer)

Aggregations

Message (com.creditease.uav.messaging.api.Message)11 MessageProducer (com.creditease.uav.messaging.api.MessageProducer)11 AgentResourceComponent (com.creditease.agent.spi.AgentResourceComponent)4 HashMap (java.util.HashMap)2 MonitorDataFrame (com.creditease.agent.monitor.api.MonitorDataFrame)1 AgentFeatureComponent (com.creditease.agent.spi.AgentFeatureComponent)1 Map (java.util.Map)1