メッセージ・ヘッダーのルーティング・アドレスの設定
メッセージ・ヘッダーにルーティング・アドレスを設定して、ファンクションを既存のメディエーション・ハンドラーに追加できます。
始める前に
このタスクについて
ルーティング・アドレスを使用する場合は、SIDestinationAddress および SIDestinationAddressFactory API を使用します。SIDestinationAddress は、 サービス統合バスを表すパブリック・インターフェースで、メディエーションに宛先名およびバス名へのアクセスを提供します。 SIDestinationAddressFactory を使用することで、サービス統合バス宛先を表す新規の SIDestinationAddress を作成することができます。 これらの API の参照情報については、SIDestinationAddressおよびSIDestinationAddressFactoryを参照してください。
手順
例
/* A sample mediation that clones a message
* and sends the clone off to another destination */
public class RoutingMediationHandler implements MediationHandler {
public String remoteDestinationName="newdest";
public boolean handle(MessageContext context) throws MessageContextException {
SIMessage clonedMessage = null;
SIMessageContext mediationContext = (SIMessageContext) context;
SIMessage message = mediationContext.getSIMessage();
SIMediationSession mediationSession = mediationContext.getSession();
// Create a forward routing path that will be set on the cloned message
Vector forwardRoutingPath = new Vector();
SIDestinationAddressFactory destFactory =
SIDestinationAddressFactory.getInstance();
SIDestinationAddress dest =
destFactory.createSIDestinationAddress(remoteDestinationName,false);
forwardRoutingPath.add(dest);
try {
// Clone the message
clonedMessage = (SIMessage) message.clone();
// Modify the forward routing path for the clone
clonedMessage.setForwardRoutingPath(forwardRoutingPath); // Send the message to the next destination in the frp
mediationSession.send(clonedMessage, false);
} catch (SIMediationRoutingException e1) {
e1.printStackTrace();
} catch (SIDestinationNotFoundException e1) {
e1.printStackTrace();
} catch (SINotAuthorizedException e1) {
e1.printStackTrace();
} catch (CloneNotSupportedException e) {
// SIMessage should clone OK so you shouldn't need to enter this block
e.printStackTrace();
}
// allow original message to continue on its path
return true;
}