Skip to content

Commit

Permalink
Interrim
Browse files Browse the repository at this point in the history
  • Loading branch information
olle committed Nov 24, 2024
1 parent cc17316 commit 1dd2db8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,38 @@
import com.studiomediatech.queryresponse.QueryResponseTopicExchange;

/**
* Configuration for ports that enable messaging, specifically AMQP including
* Query/Response.
* Configuration for ports that enable messaging, specifically AMQP including Query/Response.
*/
@Configuration
@EnableQueryResponse
@ComponentScan(basePackageClasses = MessagingConfig.class)
public class MessagingConfig {

static final String QUERY_RESPONSE_STATS_QUEUE_BEAN = "queryResponseStatsQueue";
static final String QUERY_RESPONSE_QUERIES_QUEUE_BEAN = "queryResponseQueriesQueue";

protected static final String QUERY_RESPONSE_STATS_BINDING = "queryResponseStatsBinding";
protected static final String QUERY_RESPONSE_TELEMETRY_BINDING = "queryResponseTelemetryBinding";

@Bean
ConnectionNameStrategy connectionNameStrategy(Environment env) {
return connectionFactory -> env.getProperty("spring.application.name", "query-response-ui");
}

@Bean(QUERY_RESPONSE_STATS_QUEUE_BEAN)
Queue queryResponseStatsQueue() {
return new AnonymousQueue();
}

@Bean(QUERY_RESPONSE_STATS_BINDING)
Binding queryResponseStatsQueueBinding(QueryResponseTopicExchange queryResponseTopicExchange) {
return BindingBuilder.bind(queryResponseStatsQueue()).to(queryResponseTopicExchange)
.with("query-response/internal/stats");
}

@Bean(QUERY_RESPONSE_TELEMETRY_BINDING)
Binding queryResponseTelemetryQueueBinding(QueryResponseTopicExchange queryResponseTopicExchange) {
return BindingBuilder.bind(queryResponseStatsQueue()).to(queryResponseTopicExchange)
.with("query-response/internal/telemetry");
}
static final String QUERY_RESPONSE_STATS_QUEUE_BEAN = "queryResponseStatsQueue";
static final String QUERY_RESPONSE_QUERIES_QUEUE_BEAN = "queryResponseQueriesQueue";

protected static final String QUERY_RESPONSE_STATS_BINDING = "queryResponseStatsBinding";
protected static final String QUERY_RESPONSE_TELEMETRY_BINDING = "queryResponseTelemetryBinding";

@Bean
ConnectionNameStrategy connectionNameStrategy(Environment env) {
return connectionFactory -> env.getProperty("spring.application.name", "query-response-ui");
}

@Bean(QUERY_RESPONSE_STATS_QUEUE_BEAN)
Queue queryResponseStatsQueue() {
return new AnonymousQueue();
}

@Bean(QUERY_RESPONSE_STATS_BINDING)
Binding queryResponseStatsQueueBinding(QueryResponseTopicExchange queryResponseTopicExchange) {
return BindingBuilder.bind(queryResponseStatsQueue()).to(queryResponseTopicExchange)
.with("query-response/internal/stats");
}

@Bean(QUERY_RESPONSE_TELEMETRY_BINDING)
Binding queryResponseTelemetryQueueBinding(QueryResponseTopicExchange queryResponseTopicExchange) {
return BindingBuilder.bind(queryResponseStatsQueue()).to(queryResponseTopicExchange)
.with("query-response/internal/telemetry");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ void ensure_has_telemetry_queue_with_binding() {
assertThat(binding.getRoutingKey()).isEqualTo("query-response/internal/stats");
assertThat(binding.getExchange()).isEqualTo("query-response");
}

@Test
void ensure_has_telemetry_queue_with_modernised_binding() throws Exception {
void ensure_has_telemetry_queue_with_modernised_binding() throws Exception {

Queue queue = (Queue) ctx.getBean(MessagingConfig.QUERY_RESPONSE_STATS_QUEUE_BEAN);
assertThat(queue).isNotNull();

Expand All @@ -39,5 +39,5 @@ void ensure_has_telemetry_queue_with_modernised_binding() throws Exception {
assertThat(binding.getDestination()).isEqualTo(queue.getName());
assertThat(binding.getRoutingKey()).isEqualTo("query-response/internal/telemetry");
assertThat(binding.getExchange()).isEqualTo("query-response");
}
}
}

0 comments on commit 1dd2db8

Please sign in to comment.