一部のテストクライアントでは、ローカルaws
を模倣するyopa
ライブラリを使用しています。トピックにメッセージを公開し、それを待ち行列に届けるために、私はこのようにします。メッセージをトピックにパブリッシュしてキューから受信します。
AmazonSQS amazonSQSClient = AmazonSQSClientBuilder.standard()
.withCredentials(new AWSCredentialsProvider() {
@Override
public AWSCredentials getCredentials() { return null; }
@Override
public void refresh() { }
})
.withEndpointConfiguration(new EndpointConfiguration("http://localhost:47195", "yopa-local")) // local stub
.build();
AmazonSNS amazonSNSClient = AmazonSNSClientBuilder.standard()
.withCredentials(new AWSCredentialsProvider() {
@Override
public AWSCredentials getCredentials() { return null; }
@Override
public void refresh() { }
})
.withEndpointConfiguration(new EndpointConfiguration("http://localhost:47196", "yopa-local")) // local stub
.build();
amazonSNSClient.publish("arn:aws:sns:yopa-local:000000000000:test-topic-with-subscriptions",
"This is my message");
ReceiveMessageResult message =
amazonSQSClient.receiveMessage("http://localhost:47195/queue/test-subscribed-queue-standard");
System.out.println("Number of recievied messages: " + message.getMessages().get(0));
これは問題なく動作します。
しかし、このフローを実装するにはapache camel
とspring
を使用しますか?私はこの
<routeContext id="myRoute" xmlns="http://camel.apache.org/schema/spring">
<route id="publish.route">
<from uri="bean:snsPublisher?method=publish({{sns.topic}}, ${body})"/>
<to uri="arn:aws:sns:yopa-local:000000000000:test-topic-with-subscriptions"/>
<onException redeliveryPolicyRef="redeliveryPolicy">
<exception>java.lang.Exception</exception>
<handled>
<constant>{{camel.handle.exception}}</constant>
</handled>
</onException>
</route>
</routeContext>
publisher
で豆のようなルートを作成するとき
public class SnsPublisher extends SnsClient implements IPublisher<String> {
@Override
public void publish(String topic, String message) {
try {
PublishResult publishResult = getAmazonSNSClient().publish("arn:aws:sns:yopa-local:000000000000:test-topic-with-subscriptions", message);
} catch (AmazonSNSException exception) {
}
}
}
(SnsClient
は、前の例と同じAmazonSNS
オブジェクトを提供するクラスである。)
さらには私が得るアプリケーションの開始
Caused by: org.apache.camel.ResolveEndpointFailedException:
Failed to resolve endpoint: arn://aws:sns:yopa-local:000000000000:test-topic-with-subscriptions due to: No component found with scheme: arn
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException:
Failed to create route publish.route at: >>> To[arn:aws:sns:yopa-local:000000000000:test-topic with-subscriptions] <<< in route: Route(publish.route [[From[bean:snsPublisher... because of Failed to resolve endpoint: arn://aws:sns:yopa-local:000000000000:test-topic-with-subscriptions due to: No component found with scheme: arn