既存の Mule コードを使用してメッセージを送信しようとしています。すでにいくつかのコードを作成しましたが、何らかの理由で、私が読んだ限りでは軸の「バグ」のようなものがあります。
JMSEndpoint を使用して「call」メソッドを呼び出し、メッセージを送信して応答を待ちました。これは私のコードです:
String payload = eventContext.getMessage().getPayloadAsString();
JmsConnector amqConnector = (JmsConnector) eventContext.getMuleContext().getRegistry().lookupConnector("Active_MQ");
JMSVendorAdapter adapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
QueueConnector connector = new QueueConnector(amqConnector.getConnectionFactory(), 1, 1, 2000, 2000, 60000, true, null, null, null, adapter, null);
Connection connection = connector.getConnectionFactory().createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("ExampleQueue");
JMSEndpoint endpoint = connector.createEndpoint(queue);
connector.start();
// Byte byteMessage = new Byte(payload);
// BytesMessage mess = session.createBytesMessage();
// mess.writeByte(byteMessage);
byte[] response = endpoint.call(payload.getBytes("UTF-8"), 10000);
return response.toString();
メソッド自体が byte[] を要求しているので、UTF-8 charset で byte[] を指定しています。しかし、このエラーがスローされます:
org.apache.axis.transport.jms.InvokeException: Error: unexpected message type received - expected BytesMessage
JMSConnector クラスでは、次のブロックで失敗しています。
BytesMessage response = null;
try {
response = (BytesMessage)subscriber.receive(timeout);
} catch (ClassCastException cce) {
throw new InvokeException
("Error: unexpected message type received - expected BytesMessage");
}
この問題に関して、「バグ」と呼ばれる未解決のチケットがありました??? そのため、 ClassCastException がスローされているようです。これが作られたなんて信じられない!これを解決する方法はありますか???Mule はどのようにそれを行いますか??
Mule がそのコンポーネントで行うように、JMS メッセージをキューに送信するにはどうすればよいですか?
ありがとう。