2 * Copyright 2016 [ZTE] and others.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openo.carbon.bpel.common;
18 import org.openo.carbon.bpel.externalservice.entity.ServiceRegisterEntity;
19 import org.openo.carbon.bpel.externalservice.msb.MicroserviceBusConsumer;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class ServiceRegistrer implements Runnable {
24 private static final Logger LOG = LoggerFactory.getLogger(ServiceRegistrer.class);
25 private final ServiceRegisterEntity wso2bpelEntity = new ServiceRegisterEntity();
27 public ServiceRegistrer() {
33 LOG.info("start wso2bpelEntity microservice register");
36 while (!flag && retry < 1000) {
37 LOG.info("wso2bpel microservice register.retry:" + retry);
39 flag = MicroserviceBusConsumer.registerService(wso2bpelEntity);
41 LOG.warn("microservice register failed, sleep 30S and try again.");
44 LOG.info("microservice register success!");
48 LOG.info("wso2bpel microservice register end.");
51 private void threadSleep(int second) {
52 LOG.info("start sleep ....");
55 } catch (InterruptedException error) {
56 LOG.error("thread sleep error.errorMsg:" + error.getMessage());
58 LOG.info("sleep end .");
61 private void initServiceEntity() {
62 wso2bpelEntity.setServiceName("wso2bpel");
63 wso2bpelEntity.setProtocol("REST");
64 wso2bpelEntity.setVersion("v1");
65 wso2bpelEntity.setUrl("/openoapi/wso2bpel/v1");
66 wso2bpelEntity.setSingleNode(null, "8101", 0);
67 wso2bpelEntity.setVisualRange("1");