かぐ最良のコミュニケーションのパターンEJB3-ベースのアプリケーション?
-
20-09-2019 - |
質問
思Java EEプロジェクトのニーズがなされているにすぎない。ラブル。これまでのコンセプト:
- 複数のメッセージ駆動の豆を担当し、建築
- 各MDBはセッション豆を注入し、取り扱い、ビジネスロジック
- カップルティンゲン豆へのアクセスを提供して永続化層
- 通信とは異なるパーツの建築経由要求/応答の概念によJMSメッセージ:
- MDB受信ボックスを含む活動の依頼
- を使ってセッション豆を実行に必要なビジネスロジック
- 返答のオブジェクト→自作依頼者
すると言う考えに基づいているデカップリング部品、建築からのメッセージバスであり、無制限の拡張性に単純に開始より多くのコンポーネントとして、同一バス上に接続されてい成長加速してゆくと言われています。
残念なことにまで膨大な問題の要求-応答コンセプト。取引の管理に入っているように感じられてたっぷり。で縫い目がセッション豆てはいけないことになって消費するメッセージ?!
読書 http://blogs.oracle.com/fkieviet/entry/request_reply_from_an_ejb や http://forums.sun.com/message.jspa?messageID=10338789, きちんと感を実際に推奨す 対 の要求/応答の概念をEJBs.
なお、この場合には、どのよう い コミュニケーションをきちんとEJBs?(このスケーラビリティがいので後)
詳細現在の設定:
- MDB1'TestController'を使用して(地方)SLSB1'TestService"のビジネスロジック
- TestController.onMessage()このTestServiceメッセージを送るキュー XYZ、ご要望の返信
- TestService使豆お客さまの利益を不当に
- TestService接続を確立し&セッションのJMS業者が共同で接続工場に初期化(@PostConstruct)
- TestService犯の取引後の送信、そして始まる他の取引を待ち10秒の応答
- メッセージがMDB2'LocationController'を使用する地域-地元でのSLSB2'LocationService"のビジネスロジック
- LocationController.onMessage()このLocationServiceメッセージ 裏 要求されJMSReplyToキュー
- 同BMTコンセプトと同じ@PostConstruct概念
- すべての接続工場へのアクセスの仲介
問題点:最初にメッセージが送信(SLSB1)(MDB2)okです。の送付のお車でお越しの際は、メッセージ(SLSB2)です。しかし、 SLSB1を受けないもの -それだけで回ます。
たなmessageSelector変化がない受信メッセージ。
のではないでしょうかokを消費するメッセージによるセッション豆?
SLSB1-TestService.java
@Resource(name = "jms/mvs.MVSControllerFactory")
private javax.jms.ConnectionFactory connectionFactory;
@PostConstruct
public void initialize() {
try {
jmsConnection = connectionFactory.createConnection();
session = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("Connection to JMS Provider established");
} catch (Exception e) { }
}
public Serializable sendMessageWithResponse(Destination reqDest, Destination respDest, Serializable request) {
Serializable response = null;
try {
utx.begin();
Random rand = new Random();
String correlationId = rand.nextLong() + "-" + (new Date()).getTime();
// prepare the sending message object
ObjectMessage reqMsg = session.createObjectMessage();
reqMsg.setObject(request);
reqMsg.setJMSReplyTo(respDest);
reqMsg.setJMSCorrelationID(correlationId);
// prepare the publishers and subscribers
MessageProducer producer = session.createProducer(reqDest);
// send the message
producer.send(reqMsg);
System.out.println("Request Message has been sent!");
utx.commit();
// need to start second transaction, otherwise the first msg never gets sent
utx.begin();
MessageConsumer consumer = session.createConsumer(respDest, "JMSCorrelationID = '" + correlationId + "'");
jmsConnection.start();
ObjectMessage respMsg = (ObjectMessage) consumer.receive(10000L);
utx.commit();
if (respMsg != null) {
response = respMsg.getObject();
System.out.println("Response Message has been received!");
} else {
// timeout waiting for response
System.out.println("Timeout waiting for response!");
}
} catch (Exception e) { }
return response;
}
SLSB2-LocationService.Java (回答方法は上記と同じ)
public boolean reply(Message origMsg, Serializable o) {
boolean rc = false;
try {
// check if we have necessary correlationID and replyTo destination
if (!origMsg.getJMSCorrelationID().equals("") && (origMsg.getJMSReplyTo() != null)) {
// prepare the payload
utx.begin();
ObjectMessage msg = session.createObjectMessage();
msg.setObject(o);
// make it a response
msg.setJMSCorrelationID(origMsg.getJMSCorrelationID());
Destination dest = origMsg.getJMSReplyTo();
// send it
MessageProducer producer = session.createProducer(dest);
producer.send(msg);
producer.close();
System.out.println("Reply Message has been sent");
utx.commit();
rc = true;
}
} catch (Exception e) {}
return rc;
}
sun-resources.xml
<admin-object-resource enabled="true" jndi-name="jms/mvs.LocationControllerRequest" res-type="javax.jms.Queue" res-adapter="jmsra">
<property name="Name" value="mvs.LocationControllerRequestQueue"/>
</admin-object-resource>
<admin-object-resource enabled="true" jndi-name="jms/mvs.LocationControllerResponse" res-type="javax.jms.Queue" res-adapter="jmsra">
<property name="Name" value="mvs.LocationControllerResponseQueue"/>
</admin-object-resource>
<connector-connection-pool name="jms/mvs.MVSControllerFactoryPool" connection-definition-name="javax.jms.QueueConnectionFactory" resource-adapter-name="jmsra"/>
<connector-resource enabled="true" jndi-name="jms/mvs.MVSControllerFactory" pool-name="jms/mvs.MVSControllerFactoryPool" />
解決
の要求/応答パターンを使用する場合でも、JMSは 同期 る。呼び出し側に送るメッセージを待機し、その応答が返されます。これは複雑なものに対応した最先端の画像処理にもとってからの回答、または複数のスレッドの少なくともこの場合)に割り当てられてから、無駄になっています。できない規模でこの方法:ご本質的に有限の数のスレッド)。
ついての真の提JMS建築さなければならな 非同期.その他の期間:るわけにはゆきません。メッセージの送受信に必要な情報をトリガの次の活動です。
そこでメッセージが大きすぎるときにのみの識別子に対応するデータの改善に取り組んでいます。●そのデータベースが再び点の対立を生んでいる。
と異なる場合のメッセージが必要で知る長過程に参加していることができます 相関関係識別子.実際にネットワークファイルを受信できる"履歴書"の活動の相関関係識別子です。ことになる伝統的なパターンBPEL.の同期要求/応答と非同期メッセージとの相関関係識別子がその資源の解放とする。できる規模になる。
正直、私はあまりに困惑した様長いとなればわからデザインは非同期(修正)、または同期との要求/応答(問).していますが、なんとかっている要素の答えです。
場合には、当サイトに訪問し 企業の統合のパターン, で貴重な情報源になります。