Skip to content

Commit

Permalink
eventuate-tram#13: pointless duplicate key detection should be remove…
Browse files Browse the repository at this point in the history
…d. Removed database usage from proxy (except tests)
  • Loading branch information
dartartem committed May 12, 2021
1 parent 5c382cb commit 5c2fa40
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 119 deletions.
4 changes: 0 additions & 4 deletions docker-compose-mysql-binlog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ services:
environment:
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
EVENTUATE_HTTP_PROXY_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
SPRING_DATASOURCE_USERNAME: mysqluser
SPRING_DATASOURCE_PASSWORD: mysqlpw
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
EVENTUATE_LOCAL_KAFKA_CONSUMER_PROPERTIES_SESSION_TIMEOUT_MS: 6000

proxy-follower:
Expand Down
13 changes: 0 additions & 13 deletions eventuate-tram-http-spring-consumer/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions eventuate-tram-messaging-proxy-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ dependencies {
exclude group: "io.micronaut"
}


compile "io.eventuate.tram.core:eventuate-tram-spring-consumer-jdbc:$eventuateTramVersion"
compile "io.eventuate.tram.core:eventuate-tram-spring-consumer-kafka:$eventuateTramVersion"
compile "io.eventuate.tram.core:eventuate-tram-events:$eventuateTramVersion"
compile "io.eventuate.tram.core:eventuate-tram-commands:$eventuateTramVersion"
Expand All @@ -19,8 +17,6 @@ dependencies {

compile('org.apache.curator:curator-recipes:4.2.0')

testCompile project(":eventuate-tram-http-spring-consumer")

testCompile "junit:junit:4.12"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "io.eventuate.util:eventuate-util-test:$eventuateUtilVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package io.eventuate.tram.messaging.proxy.service;

import io.eventuate.common.spring.jdbc.EventuateCommonJdbcOperationsConfiguration;
import io.eventuate.tram.consumer.common.MessageConsumerImplementation;
import io.eventuate.tram.messaging.common.ChannelMapping;
import io.eventuate.tram.messaging.common.DefaultChannelMapping;
import io.eventuate.tram.spring.consumer.jdbc.TramConsumerJdbcAutoConfiguration;
import io.eventuate.tram.spring.consumer.common.TramNoopDuplicateMessageDetectorConfiguration;
import io.eventuate.tram.spring.consumer.kafka.EventuateTramKafkaMessageConsumerConfiguration;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
Expand All @@ -19,9 +18,8 @@
import org.springframework.web.client.RestTemplate;

@Configuration
@Import({TramConsumerJdbcAutoConfiguration.class,
EventuateTramKafkaMessageConsumerConfiguration.class,
EventuateCommonJdbcOperationsConfiguration.class})
@Import({EventuateTramKafkaMessageConsumerConfiguration.class,
TramNoopDuplicateMessageDetectorConfiguration.class})
public class ProxyConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# logging.level.root=DEBUG
eventuate.http.proxy.zookeeper.connection.string=${DOCKER_HOST_IP:localhost}:2181

spring.datasource.url=jdbc:mysql://${DOCKER_HOST_IP:localhost}/eventuate
spring.datasource.username=mysqluser
spring.datasource.password=mysqlpw
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
eventuatelocal.kafka.bootstrap.servers=${DOCKER_HOST_IP:localhost}:9092
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.eventuate.tram.commands.producer.CommandProducer;
import io.eventuate.tram.consumer.http.common.HttpMessage;
import io.eventuate.tram.events.publisher.DomainEventPublisher;
import io.eventuate.tram.http.spring.consumer.duplicatedetection.IdempotentHandlerConfiguration;
import io.eventuate.tram.messaging.common.Message;
import io.eventuate.tram.messaging.producer.MessageBuilder;
import io.eventuate.tram.messaging.producer.common.MessageProducerImplementation;
Expand All @@ -13,7 +12,6 @@
import io.eventuate.tram.spring.commands.producer.TramCommandProducerConfiguration;
import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.spring.messaging.producer.jdbc.TramMessageProducerJdbcConfiguration;
import io.eventuate.util.test.async.Eventually;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -25,7 +23,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Collections;
Expand All @@ -45,8 +42,7 @@ public class EventuateHttpMessageSubscriberTest {
EventuateMessageSubscriberConfiguration.class,
TramMessageProducerJdbcConfiguration.class,
TramEventsPublisherConfiguration.class,
TramCommandProducerConfiguration.class,
IdempotentHandlerConfiguration.class})
TramCommandProducerConfiguration.class})
@EnableAutoConfiguration
@ComponentScan
@EnableAspectJAutoProxy
Expand All @@ -69,9 +65,6 @@ public SubscriptionController subscriptionController() {
@Autowired
private CommandProducer commandProducer;

@Autowired
private JdbcTemplate jdbcTemplate;

private String messageChannel = "test-channel";
private String commandChannel = "test-command-channel";
private String commandReplyChannel = "test-reply-channel";
Expand All @@ -93,22 +86,19 @@ public void init() {
public void testMessageHandled() throws InterruptedException {
sendMessage();
assertMessage();
assertMessageCheckedForDuplicate(messageId);
}

@Test
public void testEventHandled() throws InterruptedException {
sendEvent();
assertEvent();
assertMessageCheckedForDuplicate(messageId);
}

@Test
public void testCommandHandled() throws InterruptedException {
sendCommand();
assertCommand();
assertReply();
assertMessageCheckedForDuplicate(messageId);
}

private void sendCommand() {
Expand Down Expand Up @@ -180,11 +170,6 @@ private void assertMessage() throws InterruptedException {
assertEquals(messageChannel, message.getHeaders().get(Message.DESTINATION));
}

private void assertMessageCheckedForDuplicate(String id) {
Eventually.eventually(() ->
assertEquals(1, jdbcTemplate.queryForList("select * from eventuate.received_messages where message_id = ?", id).size()));
}

private String generateId() {
return UUID.randomUUID().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.eventuate.tram.messaging.common.Message;
import io.eventuate.tram.messaging.producer.MessageBuilder;
import io.eventuate.tram.messaging.producer.MessageProducer;
import io.eventuate.tram.http.spring.consumer.duplicatedetection.IdempotentHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -48,19 +47,16 @@ public BlockingQueue<TestReplyInfo> getReceivedReplies() {
}

@PostMapping(path = "/messages/s3")
@IdempotentHandler
public void handleMessages(@RequestBody HttpMessage httpMessage) {
receivedMessages.add(httpMessage);
}

@PostMapping(path = "/events/s4/TestAggregate/{aggregateId}/io.eventuate.tram.messaging.proxy.consumer.TestEvent/{eventId}")
@IdempotentHandler
public void handleEvent(@PathVariable String aggregateId, @PathVariable String eventId, @RequestBody TestEvent testEvent) {
receivedEvents.add(new TestEventInfo(testEvent, aggregateId, eventId));
}

@PostMapping(path = "/commands/d1/{messageId}/io.eventuate.tram.messaging.proxy.consumer.TestCommand/{replyChannel}/test-resource/{value}")
@IdempotentHandler
public void handleCommand(@PathVariable String messageId,
@PathVariable String replyChannel,
@PathVariable String value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -67,7 +68,7 @@ private void sendEvents() {
}

private void assertEvents() {
Eventually.eventually(() -> {
Eventually.eventually(60, 500, TimeUnit.MILLISECONDS, () -> {
assertEquals(3, customerEventController.getReceivedEvents().size());

CustomerCreditReservedEvent customerCreditReservedEvent =
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include 'eventuate-tram-consumer-http-common'
include 'eventuate-tram-messaging-proxy-service'
include 'eventuate-tram-consumer-http-micronaut'
include 'eventuate-tram-http-spring-consumer'

0 comments on commit 5c2fa40

Please sign in to comment.