@Component public class GlueEventPubActivity extends GlueActivity<GlueContext>
- producer : producer interface 정보 - method : method 이름 - param-count : parameter 수 - param# : key::type 형태. type 누락시 java.lang.String 으로 함.다음은 activity 사용 예시 입니다.
<activity name="[Client] 외부연계(producer)" class="com.poscoict.glueframework.biz.activity.GlueEventPubActivity">
<transition name="success" value="end"/>
<property name="producer" value="sample.posco.proxy.DeptEventProducer"/>
<property name="method" value="produceEvent"/>
<property name="param-count" value="1"/>
<property name="param1" value="event::sample.posco.domain.entity.DeptEvent"/>
</activity>
activity 사용 예와 관련된 sample.posco.proxy.DeptEventProducer 인터페이스와 구현클래스 입니다.
package sample.posco.proxy; import sample.posco.domain.event.DeptEvent; public interface DeptEventProducer { void pruduceEvent( DeptEvent event ); }
package sample.posco.bind; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.stream.annotation.EnableBinding; import org.springframework.integration.support.MessageBuilder; import sample.posco.domain.event.DeptEvent; import sample.posco.proxy.DeptEventProducer; @EnableBinding( DeptEventSource.class ) public class DeptEventBinder implements DeptEventProducer { @Autowired DeptEventSource eventSource; @Override public void pruduceEvent( DeptEvent event ) { eventSource.output().send( MessageBuilder.withPayload( event ).setHeader( "domain", event.getClass().getSimpleName() ).build() ); } }producer에서 사용하는 MessageChannel 은 다음과 같습니다.
package sample.posco.bind; import org.springframework.cloud.stream.annotation.Output; import org.springframework.messaging.MessageChannel; public interface DeptEventSource { @Output( "deptOutput" ) MessageChannel output(); }다음은 DeptEvent 예시입니다.
package sample.posco.domain.event; import lombok.Getter; import lombok.Setter; @Getter @Setter public class DeptEvent { private String deptno; private String dname; public DeptEvent( String deptno, String dname ) { this.deptno = deptno; this.dname = dname; } }다음은 테스트 코드 일부입니다.
@Bean public CommandLineRunner run( GlueEventPubActivity activity ) { return ( args -> { DeptEvent deptEvent = new DeptEvent( "10", "HR" ); Mapprops = new HashMap<>(); props.put( "producer", "sample.posco.proxy.DeptEventProducer" ); props.put( "method", "pruduceEvent" ); props.put( "param-count", "1" ); props.put( "param1", "event::sample.posco.domain.entity.DeptEvent" ); GlueDefaultContext ctx = new GlueDefaultContext( "no-service" ); ctx.setActivityProperties( GlueEventPubActivity.class, props ); ctx.put( "event", deptEvent ); activity.runActivity( ctx ); } ); }
Modifier and Type | Field and Description |
---|---|
protected static String |
METHOD
property : method
|
protected static String |
PARAM_COUNT
property : param-count
|
protected static String |
PRODUCER
property : producer
|
applicationContext, FAILURE, logger, RESULT_KEY, RESULT_KEY_POSTFIX, SUCCESS
Constructor and Description |
---|
GlueEventPubActivity() |
Modifier and Type | Method and Description |
---|---|
String |
runActivity(GlueContext ctx)
abstract method.
|
checkMethodName, destroy, getMethod, getParamCount, getRequiredType, getResultKey, init, makeMethodParamTypes
protected static final String PRODUCER
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.