@Component public class GlueFeignClientActivity extends GlueActivity<GlueContext>
- feign-client : FeignClient를 사용하는 interface - method : method의 이름. - param-count : parameter 수. - param# : key::type 형태. type 누락시 java.lang.String 으로 함. - result-key : Activity의 수행 결과에 대한 key 값다음은 activity 사용 예시 입니다.
<activity name="[Client] 외부연계(feign)" class="com.poscoict.glueframework.biz.activity.GlueFeignClientActivity">
<transition name="success" value="end"/>
<property name="feign-client" value="sample.third.proxy.UserClient"/>
<property name="method" value="registerUser"/>
<property name="param-count" value="1"/>
<property name="param1" value="user-value::sample.second.domain.entity.User"/>
</activity>
activity 사용 예와 관련된 sample.third.proxy.UserClient 인터페이스와 구현클래스 입니다.
package sample.third.proxy; import sample.second.domain.entity.User; public interface UserClient { String registerUser( User user ); }
package sample.third.bind; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.stereotype.Service; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import sample.second.domain.entity.User; import sample.third.proxy.UserClient; @Service @EnableCircuitBreaker @EnableFeignClients( basePackages = { "sample.second" } ) public class UserDelegator implements UserClient { @Autowired private sample.second.client.UserClient client; @Override @HystrixCommand( fallbackMethod = "failRegisterUser" ) public String registerUser( User user ) { return client.registerUser( user ); } @SuppressWarnings( "unused" ) private String failRegisterUser( User user, Throwable t ) { throw new RuntimeException( "fail to function... ", t ); } }
@Override public void modifyData( String uuid, NameValueList nameValues ) { GlueDefaultContext ctx = new GlueDefaultContext( "third-service" ); User user = new User(); user.setValues( nameValues ); Dept data = findData( uuid ); data.setValues( nameValues ); ctx.put( "Dept-value", data ); ctx.put( "user-value", user ); ctx.put( "method", "modifyData" ); bizController.doAction( ctx ); }GlueFeignClientActivity.java
Modifier and Type | Field and Description |
---|---|
protected static String |
FEIGN_CLIENT
property : feign-client
|
protected static String |
METHOD
property : method
|
protected static String |
PARAM_COUNT
property : param-count
|
applicationContext, FAILURE, logger, RESULT_KEY, RESULT_KEY_POSTFIX, SUCCESS
Constructor and Description |
---|
GlueFeignClientActivity() |
Modifier and Type | Method and Description |
---|---|
String |
runActivity(GlueContext ctx)
abstract method.
|
checkMethodName, destroy, getMethod, getParamCount, getRequiredType, getResultKey, init, makeMethodParamTypes
protected static final String FEIGN_CLIENT
protected static final String METHOD
protected static final String PARAM_COUNT
public String runActivity(GlueContext ctx)
GlueActivity
runActivity
in class GlueActivity<GlueContext>
Copyright © 2019 POSCOICT. All rights reserved.