WebSphere® MQ를 사용할 때 Message-Driven Rule Bean을 호출하려면,
사용자 정의 데이터 바인딩을 사용하여 JMS 오브젝트 메시지를 바인드해야 합니다.
이 태스크 정보
클라이언트 애플리케이션은 IBM® Process Server에서 실행하고
JMS 제공자로서 WebSphere MQ를 사용하여 Message-Driven Rule Bean을
호출할 수 있습니다.
Message-Driven Rule Bean은 JMS 오브젝트 메시지의 페이로드로서 java.util.Map을
예상하는 반면, 클라이언트 애플리케이션은 비즈니스 오브젝트를 예상합니다. 기본 JMS 데이터 바인딩은 이것을 적절하게 직렬화할 수
없습니다. 따라서 java.util.Map 인스턴스를 비즈니스 오브젝트 표시에 맵핑하는 사용자 정의 JMS 데이터 바인딩을
작성해야 합니다.
다음 예제는 지점간 메시징 모델을 사용하는 사용자 정의 데이터 바인딩을 보여줍니다.
프로시저
사용자 정의 데이터 바인딩을 구현하고 IBM Process Server에서
이 바인딩을 사용하려면 다음을 수행하십시오.
- com.ibm.websphere.sca.jms.data.JMSDataBinding 인터페이스를 구현하십시오.
다음은 해당 클래스의 스켈레톤입니다.
import javax.jms.JMSException;
import javax.jms.Message;
import com.ibm.websphere.sca.jms.data.JMSDataBinding;
import commonj.connector.runtime.DataBindingException;
import commonj.sdo.DataObject;
public class CustomerApplicationDataBinding implements JMSDataBinding {
public int getMessageType() {return 0;}
public void read(Message arg0) throws JMSException {}
public void write(Message arg0) throws JMSException {}
public boolean isBusinessException() {return false;}
public void setBusinessException(boolean arg0) {}
public DataObject getDataObject() throws DataBindingException {return null;}
public void setDataObject(DataObject arg0) throws DataBindingException {}
}
- getMessageType(), read(Message arg0) 및 write(Message arg0) 메소드의
다음 구현을 사용하여 CustApplication 비즈니스 오브젝트를 java.util.HashMap에 맵핑하십시오.
public int getMessageType() {
return JMSDataBinding.OBJECT_MESSAGE;
}
public void write(Message message) throws JMSException {
try {
ObjectMessage requestMessage = queueSession.createObjectMessage();
// Set the mandatory Rule Execution Server JMS properties.
requestMessage.setStringProperty("ilog_rules_bres_mdb_rulesetPath", rulesetPath);
requestMessage.setStringProperty("ilog_rules_bres_mdb_status", "request");
// Mandatory to get a reply message with the result of the rules execution.
requestMessage.setJMSReplyTo(replyTo);
// Set the ruleset parameters.
HashMap<String, String> parametersIn = new HashMap<String, String>();
CustApplication customerApplication = convertSDOCustApplication(customerApplicationSdo);
parametersIn.put("CustomerApplication", customerApplication);
requestMessage.setObject(parametersIn);
// Send the message.
queueSender.send(requestMessage);
} catch (DataBindingException e) {
throw new JMSException(e.getLocalizedMessage());
}
}
public void read(Message message) throws JMSException {
//Get the payload of the JMS Object message.
ObjectMessage responseMessage = (ObjectMessage) msg;
HashMap parametersOut = (HashMap) responseMessage.getObject();
// Get the number of rules fired.
str.append("\nThere are "
+ parametersOut.get("ilog.rules.firedRulesCount")
+ " rules executed\n");
// Get the value of the output report parameter.
String report = (String) parametersOut.get("report");
CustApplication outCustomerApplication =
(CustApplication) (parametersOut.get("CustomerApplication"));
// Create the business object.
DataObject dobject = convertToSDOCustApplication(outCustomerApplication);
try {
// Set the data object
setDataObject(dobject);
} catch (DataBindingException e) {
throw new JMSException(e.getLocalizedMessage());
}
}
그런 다음, IBM Process Server에서 JMS 가져오기를 작성할 수 있습니다.
- 가져오기를 마우스 오른쪽 단추로 클릭한 다음, 바인딩 생성 > 메시징 바인딩 > MQ JMS 바인딩을
클릭하십시오.
WebSphere MQ JMS 가져오기 서비스 구성 마법사가 열립니다.
- 엔드포인트 구성 아래에서 사전 구성된 메시징 제공자 자원 사용을 선택한 다음,
연결 팩토리의 JNDI 이름을 입력하고 대상을 보내며 대상을 수신하십시오.
- 선택을 클릭하여 기본 데이터 형식을 선택하십시오.
데이터 변환 구성 대화 상자가 열립니다.
- 확인을 클릭하십시오.
- 선택을 클릭하여 작업공간에서 사용자 정의 데이터 바인딩 클래스를 찾으십시오.
- 보안 구성 선택란을 선택 취소하고 완료를 클릭하십시오.
MQ JMS 가져오기가 생성됩니다.