Search in sources :

Example 1 with PullCallback

use of com.alibaba.rocketmq.client.consumer.PullCallback in project uavstack by uavorg.

the class RocketmqIT method doBefore.

public Object doBefore(Object mqClient, String methodName, Object[] args) {
    String address = getServerAddr(mqClient);
    String topic = getTopic(mqClient, methodName, args);
    String url = address + (null == topic ? "" : "/" + topic);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url);
    params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, methodName);
    params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId);
    params.put(CaptureConstants.INFO_CLIENT_TYPE, "rocketmq.client");
    if (logger.isDebugable()) {
        logger.debug("Invoke START:" + url + ",op=" + methodName, null);
    }
    // proxy the PullCallback
    if (methodName.equals("pull")) {
        PullCallback callback = null;
        if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) {
            callback = (PullCallback) args[args.length - 1];
        } else if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) {
            callback = (PullCallback) args[args.length - 2];
        }
        if (null != callback) {
            callback = JDKProxyInvokeUtil.newProxyInstance(PullCallback.class.getClassLoader(), new Class<?>[] { PullCallback.class }, new JDKProxyInvokeHandler<PullCallback>(callback, new PullCallbackProxyProcessor()));
            ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params, ccMap);
            // ivc
            ivcContext = captureInvokeChain(RocketMQPullConsumerAdapter.class, InvokeChainConstants.CapturePhase.PRECAP, params, args);
            return callback;
        }
    }
    UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params);
    if (methodName.startsWith("send")) {
        // ivc
        ivcContext = captureInvokeChain(RocketMQProducerAdapter.class, InvokeChainConstants.CapturePhase.PRECAP, params, args);
    }
    return null;
}
Also used : PullCallback(com.alibaba.rocketmq.client.consumer.PullCallback) RocketMQPullConsumerAdapter(com.creditease.uav.hook.rocketmq.adapter.RocketMQPullConsumerAdapter) HashMap(java.util.HashMap) JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) RocketMQProducerAdapter(com.creditease.uav.hook.rocketmq.adapter.RocketMQProducerAdapter)

Aggregations

PullCallback (com.alibaba.rocketmq.client.consumer.PullCallback)1 JDKProxyInvokeHandler (com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler)1 RocketMQProducerAdapter (com.creditease.uav.hook.rocketmq.adapter.RocketMQProducerAdapter)1 RocketMQPullConsumerAdapter (com.creditease.uav.hook.rocketmq.adapter.RocketMQPullConsumerAdapter)1 HashMap (java.util.HashMap)1