0

サービス統合バスは初めてです。バスを構成し、websphere ポータル サーバーをバス メンバーとして追加しました。次に、トピック接続ファクトリーを作成し、ここで作成したバスを選択しました。サービス統合バスのデフォルト トピック スペースにメッセージを送信します。JMS を使用してデフォルトのトピック スペースにメッセージを送信する方法がわかりません

4

1 に答える 1

0

残っている唯一のことは、新しいトピックを作成することです(Resources > JMS > Topics > New)、使用するトピックスペースを選択します。この場合はDefault.Topic.Spaceです。その後、次のようなコードを使用してトピックにメッセージを送信できます。

// Get the connection factory
connFactory=(ConnectionFactory)initCtx.lookup("jms/mycf");
// Get the destination used to send a message
destination = (Destination)initCtx.lookup("jms/mytopic");

Connection conn = connFactory.createConnection();
// Create a non-transacted session
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the message producer
MessageProducer msgProducer = session.createProducer(destination);
// Create the message
TextMessage txtMsg = session.createTextMessage("Hello There!!!");

 // Send the message
 msgProducer.send(txtMsg);
 session.close();
 conn.close();
于 2013-04-05T07:54:51.857 に答える