com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean Java Examples

The following examples show how to use com.xxl.rpc.remoting.invoker.reference.XxlRpcReferenceBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminBizTest.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
/**
 * registry executor
 *
 * @throws Exception
 */
@Test
public void registryTest() throws Exception {
    addressUrl = addressUrl.replace("http://", "");
    AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
            NetEnum.JETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            AdminBiz.class,
            null,
            10000,
            addressUrl,
            accessToken,
            null,
            null).getObject();

    // test executor registry
    RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
    ReturnT<String> returnT = adminBiz.registry(registryParam);
    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);

    // stop invoker
    XxlRpcInvokerFactory.getInstance().stop();
}
 
Example #2
Source File: AdminBizTest.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
/**
 * registry executor remove
 *
 * @throws Exception
 */
@Test
public void registryRemove() throws Exception {
    addressUrl = addressUrl.replace("http://", "");
    AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
            NetEnum.JETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            AdminBiz.class,
            null,
            10000,
            addressUrl,
            accessToken,
            null,
            null).getObject();

    // test executor registry remove
    RegistryParam registryParam = new RegistryParam(RegistryConfig.RegistType.EXECUTOR.name(), "xxl-job-executor-example", "127.0.0.1:9999");
    ReturnT<String> returnT = adminBiz.registryRemove(registryParam);
    Assert.assertTrue(returnT.getCode() == ReturnT.SUCCESS_CODE);

    // stop invoker
    XxlRpcInvokerFactory.getInstance().stop();
}
 
Example #3
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
private void initAdminBizList(String adminAddresses, String accessToken) throws Exception {
    if (adminAddresses != null && adminAddresses.trim().length() > 0) {
        for (String address : adminAddresses.trim().split(",")) {
            if (address != null && address.trim().length() > 0) {

                String addressUrl = address.concat(AdminBiz.MAPPING);
                if (addressUrl.startsWith("http://")) {
                    addressUrl = addressUrl.replace("http://", "");
                }
                if (addressUrl.startsWith("https://")) {
                    addressUrl = addressUrl.replace("https://", "");
                }

                AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
                        AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();

                if (adminBizList == null) {
                    adminBizList = new ArrayList<AdminBiz>();
                }
                adminBizList.add(adminBiz);
            }
        }
    }
}
 
Example #4
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
private void initAdminBizList(String adminAddresses, String accessToken) throws Exception {
    if (adminAddresses != null && adminAddresses.trim().length() > 0) {
        for (String address : adminAddresses.trim().split(",")) {
            if (address != null && address.trim().length() > 0) {

                String addressUrl = address.concat(AdminBiz.MAPPING);
                if (addressUrl.startsWith("http://")) {
                    addressUrl = addressUrl.replace("http://", "");
                }
                if (addressUrl.startsWith("https://")) {
                    addressUrl = addressUrl.replace("https://", "");
                }

                AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(NetEnum.JETTY, Serializer.SerializeEnum.HESSIAN.getSerializer(), CallType.SYNC,
                        AdminBiz.class, null, 10000, addressUrl, accessToken, null).getObject();

                if (adminBizList == null) {
                    adminBizList = new ArrayList<AdminBiz>();
                }
                adminBizList.add(adminBiz);
            }
        }
    }
}
 
Example #5
Source File: MqBrokerTest.java    From xxl-mq with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {
    String address = "127.0.0.1:7080";

    IXxlMqBroker xxlMqBroker = (IXxlMqBroker) new XxlRpcReferenceBean(
            NetEnum.NETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            IXxlMqBroker.class,
            null,
            10000,
            address,
            null,
            null,
            null).getObject();

    // test
    xxlMqBroker.addMessages(null);

}
 
Example #6
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
private void initAdminBizList(String adminAddresses, String accessToken) throws Exception {
    if (adminAddresses!=null && adminAddresses.trim().length()>0) {
        for (String address: adminAddresses.trim().split(",")) {
            if (address!=null && address.trim().length()>0) {

                String addressUrl = address.concat(AdminBiz.MAPPING);

                AdminBiz adminBiz = (AdminBiz) new XxlRpcReferenceBean(
                        NetEnum.JETTY,
                        Serializer.SerializeEnum.HESSIAN.getSerializer(),
                        CallType.SYNC,
                        LoadBalance.ROUND,
                        AdminBiz.class,
                        null,
                        10000,
                        addressUrl,
                        accessToken,
                        null,
                        null
                ).getObject();

                if (adminBizList == null) {
                    adminBizList = new ArrayList<AdminBiz>();
                }
                adminBizList.add(adminBiz);
            }
        }
    }
}
 
Example #7
Source File: ExecutorBizTest.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
/**
 * run jobhandler
 *
 * @param jobHandler
 * @param params
 */
private static void runTest(String jobHandler, String params) throws Exception {
    // trigger data
    TriggerParam triggerParam = new TriggerParam();
    triggerParam.setJobId(1);
    triggerParam.setExecutorHandler(jobHandler);
    triggerParam.setExecutorParams(params);
    triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name());
    triggerParam.setGlueType(GlueTypeEnum.BEAN.name());
    triggerParam.setGlueSource(null);
    triggerParam.setGlueUpdatetime(System.currentTimeMillis());
    triggerParam.setLogId(1);
    triggerParam.setLogDateTim(System.currentTimeMillis());

    // do remote trigger
    String accessToken = null;
    ExecutorBiz executorBiz = (ExecutorBiz) new XxlRpcReferenceBean(
            NetEnum.JETTY,
            Serializer.SerializeEnum.HESSIAN.getSerializer(),
            CallType.SYNC,
            LoadBalance.ROUND,
            ExecutorBiz.class,
            null,
            10000,
            "127.0.0.1:9999",
            null,
            null,
            null).getObject();

    ReturnT<String> runResult = executorBiz.run(triggerParam);

    System.out.println(runResult);
    XxlRpcInvokerFactory.getInstance().stop();
}